diff options
Diffstat (limited to '')
| -rw-r--r-- | src/regress/lib/libcrypto/x509/rfc3779/rfc3779.c | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/src/regress/lib/libcrypto/x509/rfc3779/rfc3779.c b/src/regress/lib/libcrypto/x509/rfc3779/rfc3779.c index efdb6516f2..33808d43e3 100644 --- a/src/regress/lib/libcrypto/x509/rfc3779/rfc3779.c +++ b/src/regress/lib/libcrypto/x509/rfc3779/rfc3779.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: rfc3779.c,v 1.8 2022/05/12 19:58:45 tb Exp $ */ | 1 | /* $OpenBSD: rfc3779.c,v 1.9 2023/04/20 07:39:17 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2021 Theo Buehler <tb@openbsd.org> | 3 | * Copyright (c) 2021 Theo Buehler <tb@openbsd.org> |
| 4 | * | 4 | * |
| @@ -322,7 +322,7 @@ run_IPAddressOrRange_tests(void) | |||
| 322 | */ | 322 | */ |
| 323 | static IPAddrBlocks *IPAddrBlocks_new(void); | 323 | static IPAddrBlocks *IPAddrBlocks_new(void); |
| 324 | static void IPAddrBlocks_free(IPAddrBlocks *addr); | 324 | static void IPAddrBlocks_free(IPAddrBlocks *addr); |
| 325 | static __unused IPAddrBlocks *d2i_IPAddrBlocks(IPAddrBlocks **addrs, | 325 | static IPAddrBlocks *d2i_IPAddrBlocks(IPAddrBlocks **addrs, |
| 326 | const unsigned char **in, long len); | 326 | const unsigned char **in, long len); |
| 327 | static int i2d_IPAddrBlocks(IPAddrBlocks *addrs, unsigned char **out); | 327 | static int i2d_IPAddrBlocks(IPAddrBlocks *addrs, unsigned char **out); |
| 328 | 328 | ||
| @@ -380,7 +380,7 @@ get_IPAddrBlocks_it(void) | |||
| 380 | return my_IPAddrBlocks_it; | 380 | return my_IPAddrBlocks_it; |
| 381 | } | 381 | } |
| 382 | 382 | ||
| 383 | static __unused IPAddrBlocks * | 383 | static IPAddrBlocks * |
| 384 | d2i_IPAddrBlocks(IPAddrBlocks **addrs, const unsigned char **in, long len) | 384 | d2i_IPAddrBlocks(IPAddrBlocks **addrs, const unsigned char **in, long len) |
| 385 | { | 385 | { |
| 386 | const ASN1_ITEM_EXP *my_IPAddrBlocks_it; | 386 | const ASN1_ITEM_EXP *my_IPAddrBlocks_it; |
| @@ -867,12 +867,13 @@ addr_block_add_addrs(IPAddrBlocks *block, const struct ip_addr_block addrs[]) | |||
| 867 | static int | 867 | static int |
| 868 | build_addr_block_test(const struct build_addr_block_test_data *test) | 868 | build_addr_block_test(const struct build_addr_block_test_data *test) |
| 869 | { | 869 | { |
| 870 | IPAddrBlocks *addrs = NULL; | 870 | IPAddrBlocks *addrs = NULL, *parsed = NULL; |
| 871 | unsigned char *out = NULL; | 871 | const unsigned char *p; |
| 872 | int out_len; | 872 | unsigned char *out = NULL; |
| 873 | int i; | 873 | int out_len; |
| 874 | int memcmp_failed = 1; | 874 | int i; |
| 875 | int failed = 1; | 875 | int memcmp_failed = 1; |
| 876 | int failed = 1; | ||
| 876 | 877 | ||
| 877 | if ((addrs = IPAddrBlocks_new()) == NULL) | 878 | if ((addrs = IPAddrBlocks_new()) == NULL) |
| 878 | goto err; | 879 | goto err; |
| @@ -943,10 +944,34 @@ build_addr_block_test(const struct build_addr_block_test_data *test) | |||
| 943 | goto err; | 944 | goto err; |
| 944 | } | 945 | } |
| 945 | 946 | ||
| 947 | p = test->der; | ||
| 948 | if ((parsed = d2i_IPAddrBlocks(NULL, &p, test->der_len)) == NULL) { | ||
| 949 | fprintf(stderr, "%s: \"%s\" d2i_IPAddrBlocks failed\n", | ||
| 950 | __func__, test->description); | ||
| 951 | goto err; | ||
| 952 | } | ||
| 953 | if (!X509v3_addr_is_canonical(parsed)) { | ||
| 954 | fprintf(stderr, "%s: \"%s\" parsed AddrBlocks isn't canonical\n", | ||
| 955 | __func__, test->description); | ||
| 956 | goto err; | ||
| 957 | } | ||
| 958 | /* Can't compare IPAddrBlocks with inheritance. */ | ||
| 959 | if (!X509v3_addr_inherits(addrs) && !X509v3_addr_inherits(parsed)) { | ||
| 960 | if (!X509v3_addr_subset(addrs, parsed)) { | ||
| 961 | fprintf(stderr, "%s: \"%s\" addrs not subset of parsed\n", | ||
| 962 | __func__, test->description); | ||
| 963 | } | ||
| 964 | if (!X509v3_addr_subset(parsed, addrs)) { | ||
| 965 | fprintf(stderr, "%s: \"%s\" parsed not subset of addrs\n", | ||
| 966 | __func__, test->description); | ||
| 967 | } | ||
| 968 | } | ||
| 969 | |||
| 946 | failed = 0; | 970 | failed = 0; |
| 947 | 971 | ||
| 948 | err: | 972 | err: |
| 949 | IPAddrBlocks_free(addrs); | 973 | IPAddrBlocks_free(addrs); |
| 974 | IPAddrBlocks_free(parsed); | ||
| 950 | free(out); | 975 | free(out); |
| 951 | 976 | ||
| 952 | return failed; | 977 | return failed; |
