diff options
Diffstat (limited to 'src/regress/lib/libcrypto/asn1/asn1time.c')
-rw-r--r-- | src/regress/lib/libcrypto/asn1/asn1time.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/regress/lib/libcrypto/asn1/asn1time.c b/src/regress/lib/libcrypto/asn1/asn1time.c index 7223ad9c9b..e0e5139808 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.30 2024/07/21 13:25:11 tb Exp $ */ | 1 | /* $OpenBSD: asn1time.c,v 1.31 2025/05/22 04:54:14 joshua 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. |
@@ -33,6 +33,7 @@ struct asn1_time_test { | |||
33 | const char *data; | 33 | const char *data; |
34 | const unsigned char der[32]; | 34 | const unsigned char der[32]; |
35 | time_t time; | 35 | time_t time; |
36 | int generalized_time; | ||
36 | }; | 37 | }; |
37 | 38 | ||
38 | static const struct asn1_time_test asn1_invtime_tests[] = { | 39 | static const struct asn1_time_test asn1_invtime_tests[] = { |
@@ -73,20 +74,19 @@ static const struct asn1_time_test asn1_invtime_tests[] = { | |||
73 | { | 74 | { |
74 | .str = "aaaaaaaaaaaaaaZ", | 75 | .str = "aaaaaaaaaaaaaaZ", |
75 | }, | 76 | }, |
76 | /* utc time with omitted seconds, should fail */ | ||
77 | { | 77 | { |
78 | /* UTC time with omitted seconds, should fail */ | ||
78 | .str = "1609082343Z", | 79 | .str = "1609082343Z", |
79 | }, | 80 | }, |
80 | }; | ||
81 | |||
82 | static const struct asn1_time_test asn1_invgentime_tests[] = { | ||
83 | /* Generalized time with omitted seconds, should fail */ | ||
84 | { | 81 | { |
82 | /* Generalized time with omitted seconds, should fail */ | ||
85 | .str = "201612081934Z", | 83 | .str = "201612081934Z", |
84 | .generalized_time = 1, | ||
86 | }, | 85 | }, |
87 | /* Valid UTC time, should fail as a generalized time */ | ||
88 | { | 86 | { |
87 | /* Valid UTC time, should fail as a generalized time */ | ||
89 | .str = "160908234300Z", | 88 | .str = "160908234300Z", |
89 | .generalized_time = 1, | ||
90 | }, | 90 | }, |
91 | }; | 91 | }; |
92 | 92 | ||
@@ -235,7 +235,7 @@ asn1_compare_str(int test_no, const struct asn1_string_st *asn1str, | |||
235 | } | 235 | } |
236 | 236 | ||
237 | static int | 237 | static int |
238 | asn1_invtime_test(int test_no, const struct asn1_time_test *att, int gen) | 238 | asn1_invtime_test(int test_no, const struct asn1_time_test *att) |
239 | { | 239 | { |
240 | ASN1_GENERALIZEDTIME *gt = NULL; | 240 | ASN1_GENERALIZEDTIME *gt = NULL; |
241 | ASN1_UTCTIME *ut = NULL; | 241 | ASN1_UTCTIME *ut = NULL; |
@@ -255,7 +255,7 @@ asn1_invtime_test(int test_no, const struct asn1_time_test *att, int gen) | |||
255 | goto done; | 255 | goto done; |
256 | } | 256 | } |
257 | 257 | ||
258 | if (gen) { | 258 | if (att->generalized_time) { |
259 | failure = 0; | 259 | failure = 0; |
260 | goto done; | 260 | goto done; |
261 | } | 261 | } |
@@ -842,13 +842,7 @@ main(int argc, char **argv) | |||
842 | fprintf(stderr, "Invalid time tests...\n"); | 842 | fprintf(stderr, "Invalid time tests...\n"); |
843 | for (i = 0; i < N_INVTIME_TESTS; i++) { | 843 | for (i = 0; i < N_INVTIME_TESTS; i++) { |
844 | att = &asn1_invtime_tests[i]; | 844 | att = &asn1_invtime_tests[i]; |
845 | failed |= asn1_invtime_test(i, att, 0); | 845 | failed |= asn1_invtime_test(i, att); |
846 | } | ||
847 | |||
848 | fprintf(stderr, "Invalid generalized time tests...\n"); | ||
849 | for (i = 0; i < N_INVGENTIME_TESTS; i++) { | ||
850 | att = &asn1_invgentime_tests[i]; | ||
851 | failed |= asn1_invtime_test(i, att, 1); | ||
852 | } | 846 | } |
853 | 847 | ||
854 | fprintf(stderr, "GENERALIZEDTIME tests...\n"); | 848 | fprintf(stderr, "GENERALIZEDTIME tests...\n"); |