diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/regress/lib/libcrypto/asn1/asn1time.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/regress/lib/libcrypto/asn1/asn1time.c b/src/regress/lib/libcrypto/asn1/asn1time.c index 95c5d24dba..b11a892300 100644 --- a/src/regress/lib/libcrypto/asn1/asn1time.c +++ b/src/regress/lib/libcrypto/asn1/asn1time.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: asn1time.c,v 1.28 2024/05/25 12:47:25 tb Exp $ */ | 1 | /* $OpenBSD: asn1time.c,v 1.29 2024/05/25 18:59:03 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2015 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2015 Joel Sing <jsing@openbsd.org> |
| 4 | * Copyright (c) 2024 Google Inc. | 4 | * Copyright (c) 2024 Google Inc. |
| @@ -121,6 +121,18 @@ static const struct asn1_time_test asn1_gentime_tests[] = { | |||
| 121 | 0x5a, | 121 | 0x5a, |
| 122 | }, | 122 | }, |
| 123 | }, | 123 | }, |
| 124 | { | ||
| 125 | /* 1 second after the 32-bit epoch wraps. */ | ||
| 126 | .str = "20380119031408Z", | ||
| 127 | .data = "20380119031408Z", | ||
| 128 | .time = 2147483648LL, | ||
| 129 | .der = { | ||
| 130 | 0x18, 0x0f, 0x32, 0x30, 0x33, 0x38, 0x30, 0x31, | ||
| 131 | 0x31, 0x39, 0x30, 0x33, 0x31, 0x34, 0x30, 0x38, | ||
| 132 | 0x5a, | ||
| 133 | }, | ||
| 134 | |||
| 135 | }, | ||
| 124 | }; | 136 | }; |
| 125 | 137 | ||
| 126 | static const struct asn1_time_test asn1_utctime_tests[] = { | 138 | static const struct asn1_time_test asn1_utctime_tests[] = { |
| @@ -280,6 +292,7 @@ asn1_gentime_test(int test_no, const struct asn1_time_test *att) | |||
| 280 | const unsigned char *der; | 292 | const unsigned char *der; |
| 281 | unsigned char *p = NULL; | 293 | unsigned char *p = NULL; |
| 282 | ASN1_GENERALIZEDTIME *gt = NULL; | 294 | ASN1_GENERALIZEDTIME *gt = NULL; |
| 295 | time_t t; | ||
| 283 | int failure = 1; | 296 | int failure = 1; |
| 284 | int len; | 297 | int len; |
| 285 | struct tm tm; | 298 | struct tm tm; |
| @@ -307,11 +320,18 @@ asn1_gentime_test(int test_no, const struct asn1_time_test *att) | |||
| 307 | goto done; | 320 | goto done; |
| 308 | } | 321 | } |
| 309 | 322 | ||
| 310 | if (timegm(&tm) != att->time) { | 323 | if (!OPENSSL_timegm(&tm, &t)) { |
| 311 | /* things with crappy time_t should die in fire */ | 324 | /* things with crappy time_t should die in fire */ |
| 312 | int64_t a = timegm(&tm); | 325 | fprintf(stderr, "FAIL: test %d - OPENSSL_timegm failed\n", |
| 313 | int64_t b = att->time; | 326 | test_no); |
| 314 | fprintf(stderr, "FAIL: test %d - times don't match, expected %lld got %lld\n", | 327 | } |
| 328 | |||
| 329 | if (t != att->time) { | ||
| 330 | /* things with crappy time_t should die in fire */ | ||
| 331 | int64_t a = t, b = att->time; | ||
| 332 | |||
| 333 | fprintf(stderr, "FAIL: test %d - times don't match, " | ||
| 334 | "expected %lld got %lld\n", | ||
| 315 | test_no, (long long)b, (long long)a); | 335 | test_no, (long long)b, (long long)a); |
| 316 | goto done; | 336 | goto done; |
| 317 | } | 337 | } |
