summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2026-01-04 09:43:52 +0000
committertb <>2026-01-04 09:43:52 +0000
commite25ccd667e01e3a9e37f06e7cc79fb7ac0f6e3f4 (patch)
tree81161faa14c0befdfce8edfa800aab0bff2b2026 /src
parentd35a685166b500418ee47359c5cfcd27c97b3eae (diff)
downloadopenbsd-e25ccd667e01e3a9e37f06e7cc79fb7ac0f6e3f4.tar.gz
openbsd-e25ccd667e01e3a9e37f06e7cc79fb7ac0f6e3f4.tar.bz2
openbsd-e25ccd667e01e3a9e37f06e7cc79fb7ac0f6e3f4.zip
asn1basic: add missing test from BoringSSL's test suite
This is another test that fails due to the bug in i2c_ASN1_BIT_STRING().
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libcrypto/asn1/asn1basic.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/regress/lib/libcrypto/asn1/asn1basic.c b/src/regress/lib/libcrypto/asn1/asn1basic.c
index e6df6559f5..0666e5b061 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.19 2026/01/04 09:42:32 tb Exp $ */ 1/* $OpenBSD: asn1basic.c,v 1.20 2026/01/04 09:43:52 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2017, 2021 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2017, 2021 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2021 Google, Inc 4 * Copyright (c) 2021 Google, Inc
@@ -237,6 +237,8 @@ static const uint8_t asn1_bit_string_10010[] = {
237 0x03, 0x02, 0x03, 0x90, 237 0x03, 0x02, 0x03, 0x90,
238}; 238};
239 239
240static const uint8_t asn1_bit_string_zeroes[64] = { 0 };
241
240static int 242static int
241asn1_bit_string_set_bit_test(void) 243asn1_bit_string_set_bit_test(void)
242{ 244{
@@ -625,6 +627,35 @@ asn1_bit_string_set_bit_test(void)
625 asn1_bit_string_1001, sizeof(asn1_bit_string_1001))) 627 asn1_bit_string_1001, sizeof(asn1_bit_string_1001)))
626 goto failed; 628 goto failed;
627 629
630 /*
631 * ASN1_BIT_STRING_set() also truncates
632 */
633
634 ASN1_BIT_STRING_free(abs);
635 abs = NULL;
636
637 if ((abs = ASN1_BIT_STRING_new()) == NULL) {
638 fprintf(stderr, "FAIL: ASN1_BIT_STRING_new\n");
639 goto failed;
640 }
641
642 if (!ASN1_STRING_set(abs, asn1_bit_string_zeroes,
643 sizeof(asn1_bit_string_zeroes))) {
644 fprintf(stderr, "FAIL: ASN1_BIT_STRING_set zeroes\n");
645 goto failed;
646 }
647
648 freezero(der, der_len);
649 der = NULL;
650 if ((der_len = i2d_ASN1_BIT_STRING(abs, &der)) <= 0) {
651 fprintf(stderr, "FAIL: i2d_ASN1_BIT_STRING\n");
652 der_len = 0;
653 goto failed;
654 }
655 if (!asn1_compare_bytes("BIT STRING all zeroes", der, der_len,
656 asn1_bit_string_empty, sizeof(asn1_bit_string_empty)))
657 goto failed;
658
628 failed = 0; 659 failed = 0;
629 660
630 failed: 661 failed: