Files
openssl/test/testutil/helper.c
Bob Beck 2fab90bb5e 4.0-POST-CLANG-FORMAT-WEBKIT
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29242)
2025-12-09 00:28:19 -07:00

41 lines
993 B
C

/*
* Copyright 2020-2025 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#include <time.h>
#include <openssl/asn1t.h>
#include <openssl/posix_time.h>
#include "../testutil.h"
int test_asn1_string_to_time_t(const char *asn1_string, time_t *out_time_t)
{
int ret = 0;
ASN1_TIME *timestamp_asn1 = NULL;
struct tm timestamp_tm;
timestamp_asn1 = ASN1_TIME_new();
if (timestamp_asn1 == NULL)
goto err;
if (!ASN1_TIME_set_string(timestamp_asn1, asn1_string))
goto err;
if (!(ASN1_TIME_to_tm(timestamp_asn1, &timestamp_tm)))
goto err;
if (!OPENSSL_timegm(&timestamp_tm, out_time_t))
goto err;
ret = 1;
err:
ASN1_TIME_free(timestamp_asn1);
return ret;
}