summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libcrypto/asn1/asn1object.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/regress/lib/libcrypto/asn1/asn1object.c b/src/regress/lib/libcrypto/asn1/asn1object.c
index 539c6aa950..56382a4edc 100644
--- a/src/regress/lib/libcrypto/asn1/asn1object.c
+++ b/src/regress/lib/libcrypto/asn1/asn1object.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn1object.c,v 1.10 2022/11/26 16:08:56 tb Exp $ */ 1/* $OpenBSD: asn1object.c,v 1.11 2024/05/29 16:19:50 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2017, 2021, 2022 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2017, 2021, 2022 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -25,9 +25,14 @@
25#include "asn1_local.h" 25#include "asn1_local.h"
26 26
27static void 27static void
28hexdump(const unsigned char *buf, size_t len) 28hexdump(const unsigned char *buf, int len)
29{ 29{
30 size_t i; 30 int i;
31
32 if (len <= 0) {
33 fprintf(stderr, "<negative length %d>\n", len);
34 return;
35 }
31 36
32 for (i = 1; i <= len; i++) 37 for (i = 1; i <= len; i++)
33 fprintf(stderr, " 0x%02hhx,%s", buf[i - 1], i % 8 ? "" : "\n"); 38 fprintf(stderr, " 0x%02hhx,%s", buf[i - 1], i % 8 ? "" : "\n");
@@ -223,6 +228,7 @@ do_asn1_object_test(struct asn1_object_test *aot)
223 ASN1_OBJECT *aobj = NULL; 228 ASN1_OBJECT *aobj = NULL;
224 uint8_t buf[1024]; 229 uint8_t buf[1024];
225 const uint8_t *p; 230 const uint8_t *p;
231 uint8_t *der = NULL;
226 uint8_t *q; 232 uint8_t *q;
227 int err, ret; 233 int err, ret;
228 int failed = 1; 234 int failed = 1;
@@ -268,6 +274,15 @@ do_asn1_object_test(struct asn1_object_test *aot)
268 aot->der_len)) 274 aot->der_len))
269 goto failed; 275 goto failed;
270 276
277 der = NULL;
278 ret = i2d_ASN1_OBJECT(aobj, &der);
279 if (!asn1_compare_bytes("ASN1_OBJECT DER", der, ret, aot->der,
280 aot->der_len))
281 goto failed;
282
283 free(der);
284 der = NULL;
285
271 ASN1_OBJECT_free(aobj); 286 ASN1_OBJECT_free(aobj);
272 aobj = NULL; 287 aobj = NULL;
273 288
@@ -300,6 +315,7 @@ do_asn1_object_test(struct asn1_object_test *aot)
300 315
301 failed: 316 failed:
302 ASN1_OBJECT_free(aobj); 317 ASN1_OBJECT_free(aobj);
318 free(der);
303 319
304 return failed; 320 return failed;
305} 321}
@@ -455,6 +471,7 @@ asn1_object_large_oid_test(void)
455 ASN1_OBJECT *aobj = NULL; 471 ASN1_OBJECT *aobj = NULL;
456 uint8_t buf[1024]; 472 uint8_t buf[1024];
457 const uint8_t *p; 473 const uint8_t *p;
474 uint8_t *der = NULL;
458 uint8_t *q; 475 uint8_t *q;
459 int ret; 476 int ret;
460 int failed = 1; 477 int failed = 1;
@@ -475,8 +492,15 @@ asn1_object_large_oid_test(void)
475 sizeof(asn1_large_oid_der))) 492 sizeof(asn1_large_oid_der)))
476 goto failed; 493 goto failed;
477 494
495 der = NULL;
496 ret = i2d_ASN1_OBJECT(aobj, &der);
497 if (!asn1_compare_bytes("ASN1_OBJECT DER", der, ret, asn1_large_oid_der,
498 sizeof(asn1_large_oid_der)))
499 goto failed;
500
478 failed: 501 failed:
479 ASN1_OBJECT_free(aobj); 502 ASN1_OBJECT_free(aobj);
503 free(der);
480 504
481 return failed; 505 return failed;
482} 506}