diff options
author | shridhar kalavagunta <coolshrid@hotmail.com> | 2024-01-11 17:01:23 -0600 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2024-05-07 12:07:49 +0200 |
commit | 57bb112c07116d1cdbf5bc8562ebb3e7990f291c (patch) | |
tree | 05e04e4c4a63d52c791dcfc324c7a19203fd4553 /crypto | |
parent | 69bd5e4fff8ac9bf4dc3ed6fd87b5a5858edbb01 (diff) | |
download | openssl-57bb112c07116d1cdbf5bc8562ebb3e7990f291c.tar.gz |
Move ossl_asn1_string_to_time_t() to libtestutil
It is not used anywhere else than in tests.
Fixes #22965
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23269)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/asn1/a_time.c | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/crypto/asn1/a_time.c b/crypto/asn1/a_time.c index 96ee63d310..7dfbc5faab 100644 --- a/crypto/asn1/a_time.c +++ b/crypto/asn1/a_time.c @@ -591,78 +591,3 @@ int ASN1_TIME_compare(const ASN1_TIME *a, const ASN1_TIME *b) return -1; return 0; } - -/* - * tweak for Windows - */ -#ifdef WIN32 -# define timezone _timezone -#endif - -#if defined(__FreeBSD__) || defined(__wasi__) -# define USE_TIMEGM -#endif - -time_t ossl_asn1_string_to_time_t(const char *asn1_string) -{ - ASN1_TIME *timestamp_asn1 = NULL; - struct tm *timestamp_tm = NULL; -#if defined(__DJGPP__) - char *tz = NULL; -#elif !defined(USE_TIMEGM) - time_t timestamp_local; -#endif - time_t timestamp_utc; - - timestamp_asn1 = ASN1_TIME_new(); - if (!ASN1_TIME_set_string(timestamp_asn1, asn1_string)) - { - ASN1_TIME_free(timestamp_asn1); - return -1; - } - - timestamp_tm = OPENSSL_malloc(sizeof(*timestamp_tm)); - if (timestamp_tm == NULL) { - ASN1_TIME_free(timestamp_asn1); - return -1; - } - if (!(ASN1_TIME_to_tm(timestamp_asn1, timestamp_tm))) { - OPENSSL_free(timestamp_tm); - ASN1_TIME_free(timestamp_asn1); - return -1; - } - ASN1_TIME_free(timestamp_asn1); - -#if defined(__DJGPP__) - /* - * This is NOT thread-safe. Do not use this method for platforms other - * than djgpp. - */ - tz = getenv("TZ"); - if (tz != NULL) { - tz = OPENSSL_strdup(tz); - if (tz == NULL) { - OPENSSL_free(timestamp_tm); - return -1; - } - } - setenv("TZ", "UTC", 1); - - timestamp_utc = mktime(timestamp_tm); - - if (tz != NULL) { - setenv("TZ", tz, 1); - OPENSSL_free(tz); - } else { - unsetenv("TZ"); - } -#elif defined(USE_TIMEGM) - timestamp_utc = timegm(timestamp_tm); -#else - timestamp_local = mktime(timestamp_tm); - timestamp_utc = timestamp_local - timezone; -#endif - OPENSSL_free(timestamp_tm); - - return timestamp_utc; -} |