summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2023-10-02 09:42:58 +0000
committertb <>2023-10-02 09:42:58 +0000
commit81eaf95b8c0fc8721189ab568d84e140e4d163ca (patch)
tree9f08d68070e4d468f60945dcdad46cd56505c8c7
parent630c0d89dbfd82560150ff8a20f87b9400f78b4d (diff)
downloadopenbsd-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.c38
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
31struct asn1_time_test asn1_invtime_tests[] = { 31static 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
75struct asn1_time_test asn1_invgentime_tests[] = { 75static 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
86struct asn1_time_test asn1_goodtime_tests[] = { 86static 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
101struct 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
134struct asn1_time_test asn1_utctime_tests[] = { 119static 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
213static int 198static int
214asn1_compare_str(int test_no, struct asn1_string_st *asn1str, const char *str) 199asn1_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
232static int 218static int
233asn1_invtime_test(int test_no, struct asn1_time_test *att, int gen) 219asn1_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
284static int 270static int
285asn1_gentime_test(int test_no, struct asn1_time_test *att) 271asn1_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
363static int 349static int
364asn1_utctime_test(int test_no, struct asn1_time_test *att) 350asn1_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
426static int 412static int
427asn1_time_test(int test_no, struct asn1_time_test *att, int type) 413asn1_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)
490int 476int
491main(int argc, char **argv) 477main(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