diff options
author | tb <> | 2023-10-02 09:42:58 +0000 |
---|---|---|
committer | tb <> | 2023-10-02 09:42:58 +0000 |
commit | 81eaf95b8c0fc8721189ab568d84e140e4d163ca (patch) | |
tree | 9f08d68070e4d468f60945dcdad46cd56505c8c7 | |
parent | 630c0d89dbfd82560150ff8a20f87b9400f78b4d (diff) | |
download | openbsd-81eaf95b8c0fc8721189ab568d84e140e4d163ca.tar.gz openbsd-81eaf95b8c0fc8721189ab568d84e140e4d163ca.tar.bz2 openbsd-81eaf95b8c0fc8721189ab568d84e140e4d163ca.zip |
Minor asn1time tweaks
Sprinkle some (static) const and garbage collect an unused struct.
-rw-r--r-- | src/regress/lib/libcrypto/asn1/asn1time.c | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/src/regress/lib/libcrypto/asn1/asn1time.c b/src/regress/lib/libcrypto/asn1/asn1time.c index 65c36dfb01..c6e13b0b20 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.17 2023/08/30 10:13:12 job Exp $ */ | 1 | /* $OpenBSD: asn1time.c,v 1.18 2023/10/02 09:42:58 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2015 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2015 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -28,7 +28,7 @@ struct asn1_time_test { | |||
28 | time_t time; | 28 | time_t time; |
29 | }; | 29 | }; |
30 | 30 | ||
31 | struct asn1_time_test asn1_invtime_tests[] = { | 31 | static const struct asn1_time_test asn1_invtime_tests[] = { |
32 | { | 32 | { |
33 | .str = "", | 33 | .str = "", |
34 | }, | 34 | }, |
@@ -72,7 +72,7 @@ struct asn1_time_test asn1_invtime_tests[] = { | |||
72 | }, | 72 | }, |
73 | }; | 73 | }; |
74 | 74 | ||
75 | struct asn1_time_test asn1_invgentime_tests[] = { | 75 | static const struct asn1_time_test asn1_invgentime_tests[] = { |
76 | /* Generalized time with omitted seconds, should fail */ | 76 | /* Generalized time with omitted seconds, should fail */ |
77 | { | 77 | { |
78 | .str = "201612081934Z", | 78 | .str = "201612081934Z", |
@@ -83,22 +83,7 @@ struct asn1_time_test asn1_invgentime_tests[] = { | |||
83 | }, | 83 | }, |
84 | }; | 84 | }; |
85 | 85 | ||
86 | struct asn1_time_test asn1_goodtime_tests[] = { | 86 | static const struct asn1_time_test asn1_gentime_tests[] = { |
87 | { | ||
88 | .str = "99990908234339Z", | ||
89 | .time = 1, | ||
90 | }, | ||
91 | { | ||
92 | .str = "201612081934Z", | ||
93 | .time = 1, | ||
94 | }, | ||
95 | { | ||
96 | .str = "1609082343Z", | ||
97 | .time = 0, | ||
98 | }, | ||
99 | }; | ||
100 | |||
101 | struct asn1_time_test asn1_gentime_tests[] = { | ||
102 | { | 87 | { |
103 | .str = "20161208193400Z", | 88 | .str = "20161208193400Z", |
104 | .data = "20161208193400Z", | 89 | .data = "20161208193400Z", |
@@ -131,7 +116,7 @@ struct asn1_time_test asn1_gentime_tests[] = { | |||
131 | }, | 116 | }, |
132 | }; | 117 | }; |
133 | 118 | ||
134 | struct asn1_time_test asn1_utctime_tests[] = { | 119 | static const struct asn1_time_test asn1_utctime_tests[] = { |
135 | { | 120 | { |
136 | .str = "700101000000Z", | 121 | .str = "700101000000Z", |
137 | .data = "700101000000Z", | 122 | .data = "700101000000Z", |
@@ -211,7 +196,8 @@ asn1_compare_bytes(int test_no, const unsigned char *d1, | |||
211 | } | 196 | } |
212 | 197 | ||
213 | static int | 198 | static int |
214 | asn1_compare_str(int test_no, struct asn1_string_st *asn1str, const char *str) | 199 | asn1_compare_str(int test_no, const struct asn1_string_st *asn1str, |
200 | const char *str) | ||
215 | { | 201 | { |
216 | int length = strlen(str); | 202 | int length = strlen(str); |
217 | 203 | ||
@@ -230,7 +216,7 @@ asn1_compare_str(int test_no, struct asn1_string_st *asn1str, const char *str) | |||
230 | } | 216 | } |
231 | 217 | ||
232 | static int | 218 | static int |
233 | asn1_invtime_test(int test_no, struct asn1_time_test *att, int gen) | 219 | asn1_invtime_test(int test_no, const struct asn1_time_test *att, int gen) |
234 | { | 220 | { |
235 | ASN1_GENERALIZEDTIME *gt = NULL; | 221 | ASN1_GENERALIZEDTIME *gt = NULL; |
236 | ASN1_UTCTIME *ut = NULL; | 222 | ASN1_UTCTIME *ut = NULL; |
@@ -282,7 +268,7 @@ asn1_invtime_test(int test_no, struct asn1_time_test *att, int gen) | |||
282 | } | 268 | } |
283 | 269 | ||
284 | static int | 270 | static int |
285 | asn1_gentime_test(int test_no, struct asn1_time_test *att) | 271 | asn1_gentime_test(int test_no, const struct asn1_time_test *att) |
286 | { | 272 | { |
287 | const unsigned char *der; | 273 | const unsigned char *der; |
288 | unsigned char *p = NULL; | 274 | unsigned char *p = NULL; |
@@ -361,7 +347,7 @@ asn1_gentime_test(int test_no, struct asn1_time_test *att) | |||
361 | } | 347 | } |
362 | 348 | ||
363 | static int | 349 | static int |
364 | asn1_utctime_test(int test_no, struct asn1_time_test *att) | 350 | asn1_utctime_test(int test_no, const struct asn1_time_test *att) |
365 | { | 351 | { |
366 | const unsigned char *der; | 352 | const unsigned char *der; |
367 | unsigned char *p = NULL; | 353 | unsigned char *p = NULL; |
@@ -424,7 +410,7 @@ asn1_utctime_test(int test_no, struct asn1_time_test *att) | |||
424 | } | 410 | } |
425 | 411 | ||
426 | static int | 412 | static int |
427 | asn1_time_test(int test_no, struct asn1_time_test *att, int type) | 413 | asn1_time_test(int test_no, const struct asn1_time_test *att, int type) |
428 | { | 414 | { |
429 | ASN1_TIME *t = NULL, *tx509 = NULL; | 415 | ASN1_TIME *t = NULL, *tx509 = NULL; |
430 | int failure = 1; | 416 | int failure = 1; |
@@ -490,7 +476,7 @@ asn1_time_test(int test_no, struct asn1_time_test *att, int type) | |||
490 | int | 476 | int |
491 | main(int argc, char **argv) | 477 | main(int argc, char **argv) |
492 | { | 478 | { |
493 | struct asn1_time_test *att; | 479 | const struct asn1_time_test *att; |
494 | int failed = 0; | 480 | int failed = 0; |
495 | size_t i; | 481 | size_t i; |
496 | 482 | ||