diff options
author | jsing <> | 2022-09-03 18:54:36 +0000 |
---|---|---|
committer | jsing <> | 2022-09-03 18:54:36 +0000 |
commit | 25572a0a4f89d920a5a347726cac519fa63acb7c (patch) | |
tree | 5eb69afe07f99c7c50a8898f0d16739e95a3eed2 | |
parent | 0cd135545398370513764fd74cd8a8871ef351cc (diff) | |
download | openbsd-25572a0a4f89d920a5a347726cac519fa63acb7c.tar.gz openbsd-25572a0a4f89d920a5a347726cac519fa63acb7c.tar.bz2 openbsd-25572a0a4f89d920a5a347726cac519fa63acb7c.zip |
Ensure a constructed ASN.1 INTEGER is considered invalid when decoding.
-rw-r--r-- | src/regress/lib/libcrypto/asn1/asn1basic.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/regress/lib/libcrypto/asn1/asn1basic.c b/src/regress/lib/libcrypto/asn1/asn1basic.c index 9ab23e7849..6ce27a2706 100644 --- a/src/regress/lib/libcrypto/asn1/asn1basic.c +++ b/src/regress/lib/libcrypto/asn1/asn1basic.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: asn1basic.c,v 1.10 2022/08/28 17:59:57 jsing Exp $ */ | 1 | /* $OpenBSD: asn1basic.c,v 1.11 2022/09/03 18:54:36 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2017, 2021 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2017, 2021 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -16,6 +16,7 @@ | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <openssl/asn1.h> | 18 | #include <openssl/asn1.h> |
19 | #include <openssl/err.h> | ||
19 | 20 | ||
20 | #include <err.h> | 21 | #include <err.h> |
21 | #include <stdio.h> | 22 | #include <stdio.h> |
@@ -359,6 +360,18 @@ struct asn1_integer_test asn1_integer_tests[] = { | |||
359 | .der_len = 11, | 360 | .der_len = 11, |
360 | .want_error = 1, | 361 | .want_error = 1, |
361 | }, | 362 | }, |
363 | { | ||
364 | /* Invalid encoding (constructed with definite length). */ | ||
365 | .der = {0x22, 0x03, 0x02, 0x01, 0x01}, | ||
366 | .der_len = 5, | ||
367 | .want_error = 1, | ||
368 | }, | ||
369 | { | ||
370 | /* Invalid encoding (constructed with indefinite length). */ | ||
371 | .der = {0x22, 0x80, 0x02, 0x01, 0x01, 0x00, 0x00}, | ||
372 | .der_len = 7, | ||
373 | .want_error = 1, | ||
374 | }, | ||
362 | }; | 375 | }; |
363 | 376 | ||
364 | #define N_ASN1_INTEGER_TESTS \ | 377 | #define N_ASN1_INTEGER_TESTS \ |
@@ -492,6 +505,7 @@ asn1_integer_decode_test(struct asn1_integer_test *ait) | |||
492 | } | 505 | } |
493 | } else if (ait->want_error == 0) { | 506 | } else if (ait->want_error == 0) { |
494 | fprintf(stderr, "FAIL: INTEGER failed to decode\n"); | 507 | fprintf(stderr, "FAIL: INTEGER failed to decode\n"); |
508 | ERR_print_errors_fp(stderr); | ||
495 | goto failed; | 509 | goto failed; |
496 | } | 510 | } |
497 | 511 | ||