From 5f2eabbbce48ad8c794c6923b8e985ef442b88dc Mon Sep 17 00:00:00 2001 From: tb Date: Fri, 24 Dec 2021 02:41:35 +0000 Subject: [PATCH] Fix some KNF issues in the RFC 3779 section that have bothered me for way too long. --- lib/libcrypto/x509/x509v3.h | 109 ++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/lib/libcrypto/x509/x509v3.h b/lib/libcrypto/x509/x509v3.h index 2d8ab6fc6e8..0a6d4393108 100644 --- a/lib/libcrypto/x509/x509v3.h +++ b/lib/libcrypto/x509/x509v3.h @@ -1,4 +1,4 @@ -/* $OpenBSD: x509v3.h,v 1.10 2021/11/01 08:14:36 tb Exp $ */ +/* $OpenBSD: x509v3.h,v 1.11 2021/12/24 02:41:35 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -850,36 +850,38 @@ DECLARE_STACK_OF(X509_POLICY_NODE) #if defined(LIBRESSL_INTERNAL) #ifndef OPENSSL_NO_RFC3779 typedef struct ASRange_st { - ASN1_INTEGER *min, *max; + ASN1_INTEGER *min; + ASN1_INTEGER *max; } ASRange; -# define ASIdOrRange_id 0 -# define ASIdOrRange_range 1 +#define ASIdOrRange_id 0 +#define ASIdOrRange_range 1 typedef struct ASIdOrRange_st { - int type; - union { - ASN1_INTEGER *id; - ASRange *range; - } u; + int type; + union { + ASN1_INTEGER *id; + ASRange *range; + } u; } ASIdOrRange; typedef STACK_OF(ASIdOrRange) ASIdOrRanges; DECLARE_STACK_OF(ASIdOrRange) -# define ASIdentifierChoice_inherit 0 -# define ASIdentifierChoice_asIdsOrRanges 1 +#define ASIdentifierChoice_inherit 0 +#define ASIdentifierChoice_asIdsOrRanges 1 typedef struct ASIdentifierChoice_st { - int type; - union { - ASN1_NULL *inherit; - ASIdOrRanges *asIdsOrRanges; - } u; + int type; + union { + ASN1_NULL *inherit; + ASIdOrRanges *asIdsOrRanges; + } u; } ASIdentifierChoice; typedef struct ASIdentifiers_st { - ASIdentifierChoice *asnum, *rdi; + ASIdentifierChoice *asnum; + ASIdentifierChoice *rdi; } ASIdentifiers; ASRange *ASRange_new(void); @@ -910,37 +912,38 @@ int i2d_ASIdentifiers(ASIdentifiers *a, unsigned char **out); extern const ASN1_ITEM ASIdentifiers_it; typedef struct IPAddressRange_st { - ASN1_BIT_STRING *min, *max; + ASN1_BIT_STRING *min; + ASN1_BIT_STRING *max; } IPAddressRange; -# define IPAddressOrRange_addressPrefix 0 -# define IPAddressOrRange_addressRange 1 +#define IPAddressOrRange_addressPrefix 0 +#define IPAddressOrRange_addressRange 1 typedef struct IPAddressOrRange_st { - int type; - union { - ASN1_BIT_STRING *addressPrefix; - IPAddressRange *addressRange; - } u; + int type; + union { + ASN1_BIT_STRING *addressPrefix; + IPAddressRange *addressRange; + } u; } IPAddressOrRange; typedef STACK_OF(IPAddressOrRange) IPAddressOrRanges; DECLARE_STACK_OF(IPAddressOrRange) -# define IPAddressChoice_inherit 0 -# define IPAddressChoice_addressesOrRanges 1 +#define IPAddressChoice_inherit 0 +#define IPAddressChoice_addressesOrRanges 1 typedef struct IPAddressChoice_st { - int type; - union { - ASN1_NULL *inherit; - IPAddressOrRanges *addressesOrRanges; - } u; + int type; + union { + ASN1_NULL *inherit; + IPAddressOrRanges *addressesOrRanges; + } u; } IPAddressChoice; typedef struct IPAddressFamily_st { - ASN1_OCTET_STRING *addressFamily; - IPAddressChoice *ipAddressChoice; + ASN1_OCTET_STRING *addressFamily; + IPAddressChoice *ipAddressChoice; } IPAddressFamily; typedef STACK_OF(IPAddressFamily) IPAddrBlocks; @@ -977,8 +980,8 @@ extern const ASN1_ITEM IPAddressFamily_it; /* * API tag for elements of the ASIdentifer SEQUENCE. */ -# define V3_ASID_ASNUM 0 -# define V3_ASID_RDI 1 +#define V3_ASID_ASNUM 0 +#define V3_ASID_RDI 1 /* * AFI values, assigned by IANA. It'd be nice to make the AFI @@ -986,8 +989,9 @@ extern const ASN1_ITEM IPAddressFamily_it; * that would need to be defined for other address families for it to * be worth the trouble. */ -# define IANA_AFI_IPV4 1 -# define IANA_AFI_IPV6 2 +#define IANA_AFI_IPV4 1 +#define IANA_AFI_IPV6 2 + /* * Utilities to construct and extract values from RFC3779 extensions, * since some of the encodings (particularly for IP address prefixes @@ -995,19 +999,17 @@ extern const ASN1_ITEM IPAddressFamily_it; */ int X509v3_asid_add_inherit(ASIdentifiers *asid, int which); int X509v3_asid_add_id_or_range(ASIdentifiers *asid, int which, - ASN1_INTEGER *min, ASN1_INTEGER *max); -int X509v3_addr_add_inherit(IPAddrBlocks *addr, - const unsigned afi, const unsigned *safi); -int X509v3_addr_add_prefix(IPAddrBlocks *addr, - const unsigned afi, const unsigned *safi, - unsigned char *a, const int prefixlen); -int X509v3_addr_add_range(IPAddrBlocks *addr, - const unsigned afi, const unsigned *safi, - unsigned char *min, unsigned char *max); + ASN1_INTEGER *min, ASN1_INTEGER *max); +int X509v3_addr_add_inherit(IPAddrBlocks *addr, const unsigned afi, + const unsigned *safi); +int X509v3_addr_add_prefix(IPAddrBlocks *addr, const unsigned afi, + const unsigned *safi, unsigned char *a, const int prefixlen); +int X509v3_addr_add_range(IPAddrBlocks *addr, const unsigned afi, + const unsigned *safi, unsigned char *min, unsigned char *max); unsigned X509v3_addr_get_afi(const IPAddressFamily *f); int X509v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi, - unsigned char *min, unsigned char *max, - const int length); + unsigned char *min, unsigned char *max, const int length); + /* * Canonical forms. */ @@ -1029,11 +1031,10 @@ int X509v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b); */ int X509v3_asid_validate_path(X509_STORE_CTX *); int X509v3_addr_validate_path(X509_STORE_CTX *); -int X509v3_asid_validate_resource_set(STACK_OF(X509) *chain, - ASIdentifiers *ext, - int allow_inheritance); -int X509v3_addr_validate_resource_set(STACK_OF(X509) *chain, - IPAddrBlocks *ext, int allow_inheritance); +int X509v3_asid_validate_resource_set(STACK_OF(X509) *chain, ASIdentifiers *ext, + int allow_inheritance); +int X509v3_addr_validate_resource_set(STACK_OF(X509) *chain, IPAddrBlocks *ext, + int allow_inheritance); #endif /* OPENSSL_NO_RFC3779 */ #endif -- 2.20.1