summaryrefslogtreecommitdiff
path: root/src/regress
diff options
context:
space:
mode:
Diffstat (limited to 'src/regress')
-rw-r--r--src/regress/lib/libcrypto/asn1/asn1time.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/regress/lib/libcrypto/asn1/asn1time.c b/src/regress/lib/libcrypto/asn1/asn1time.c
index 6bbbf393a1..d3927929ca 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.9 2021/12/09 16:31:33 jsing Exp $ */ 1/* $OpenBSD: asn1time.c,v 1.10 2022/06/27 13:54:58 beck Exp $ */
2/* 2/*
3 * Copyright (c) 2015 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2015 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -217,6 +217,11 @@ asn1_invtime_test(int test_no, struct asn1_time_test *att)
217 "string '%s'\n", test_no, att->str); 217 "string '%s'\n", test_no, att->str);
218 goto done; 218 goto done;
219 } 219 }
220 if (ASN1_TIME_set_string_x509(t, att->str) != 0) {
221 fprintf(stderr, "FAIL: test %i - successfully set x509 TIME "
222 "string '%s'\n", test_no, att->str);
223 goto done;
224 }
220 225
221 failure = 0; 226 failure = 0;
222 227
@@ -357,7 +362,7 @@ asn1_utctime_test(int test_no, struct asn1_time_test *att)
357static int 362static int
358asn1_time_test(int test_no, struct asn1_time_test *att, int type) 363asn1_time_test(int test_no, struct asn1_time_test *att, int type)
359{ 364{
360 ASN1_TIME *t = NULL; 365 ASN1_TIME *t = NULL, *tx509 = NULL;
361 int failure = 1; 366 int failure = 1;
362 367
363 if (ASN1_TIME_set_string(NULL, att->str) != 1) { 368 if (ASN1_TIME_set_string(NULL, att->str) != 1) {
@@ -369,6 +374,9 @@ asn1_time_test(int test_no, struct asn1_time_test *att, int type)
369 if ((t = ASN1_TIME_new()) == NULL) 374 if ((t = ASN1_TIME_new()) == NULL)
370 goto done; 375 goto done;
371 376
377 if ((tx509 = ASN1_TIME_new()) == NULL)
378 goto done;
379
372 if (ASN1_TIME_set_string(t, att->str) != 1) { 380 if (ASN1_TIME_set_string(t, att->str) != 1) {
373 fprintf(stderr, "FAIL: test %i - failed to set string '%s'\n", 381 fprintf(stderr, "FAIL: test %i - failed to set string '%s'\n",
374 test_no, att->str); 382 test_no, att->str);
@@ -381,11 +389,36 @@ asn1_time_test(int test_no, struct asn1_time_test *att, int type)
381 goto done; 389 goto done;
382 } 390 }
383 391
392 if (ASN1_TIME_normalize(t) != 1) {
393 fprintf(stderr, "FAIL: test %i - failed to set normalize '%s'\n",
394 test_no, att->str);
395 goto done;
396 }
397
398 if (ASN1_TIME_set_string_x509(tx509, t->data) != 1) {
399 fprintf(stderr, "FAIL: test %i - failed to set string X509 '%s'\n",
400 test_no, t->data);
401 goto done;
402 }
403
404 if (t->type != tx509->type) {
405 fprintf(stderr, "FAIL: test %i - type %d, different from %d\n",
406 test_no, t->type, tx509->type);
407 goto done;
408 }
409
410 if (ASN1_TIME_compare(t, tx509) != 0) {
411 fprintf(stderr, "FAIL: ASN1_TIME values differ!\n");
412 goto done;
413 }
414
415
384 failure = 0; 416 failure = 0;
385 417
386 done: 418 done:
387 419
388 ASN1_TIME_free(t); 420 ASN1_TIME_free(t);
421 ASN1_TIME_free(tx509);
389 422
390 return (failure); 423 return (failure);
391} 424}