From 1e9dee7329a30d1e3e557f48fd7f58e6ad1fde43 Mon Sep 17 00:00:00 2001 From: tb Date: Sat, 25 Dec 2021 15:42:32 +0000 Subject: [PATCH] Use C99 initializers for v3_addr, v3_asid and v3_ct_scts[] as is done for most other X.509 v3 extension methods. discussed with jsing --- lib/libcrypto/ct/ct_x509v3.c | 70 ++++++++++++++++++++++++---------- lib/libcrypto/x509/x509_addr.c | 27 +++++++------ lib/libcrypto/x509/x509_asid.c | 27 +++++++------ 3 files changed, 79 insertions(+), 45 deletions(-) diff --git a/lib/libcrypto/ct/ct_x509v3.c b/lib/libcrypto/ct/ct_x509v3.c index 82a5c2be5d1..59f2975cd91 100644 --- a/lib/libcrypto/ct/ct_x509v3.c +++ b/lib/libcrypto/ct/ct_x509v3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ct_x509v3.c,v 1.5 2021/12/18 16:34:52 tb Exp $ */ +/* $OpenBSD: ct_x509v3.c,v 1.6 2021/12/25 15:42:32 tb Exp $ */ /* * Written by Rob Stradling (rob@comodo.com) and Stephen Henson * (steve@openssl.org) for the OpenSSL project 2014. @@ -131,28 +131,56 @@ ocsp_ext_d2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp, long len) /* Handlers for X509v3/OCSP Certificate Transparency extensions */ const X509V3_EXT_METHOD v3_ct_scts[3] = { /* X509v3 extension in certificates that contains SCTs */ - { NID_ct_precert_scts, 0, NULL, - NULL, (X509V3_EXT_FREE)SCT_LIST_free, - (X509V3_EXT_D2I)x509_ext_d2i_SCT_LIST, (X509V3_EXT_I2D)i2d_SCT_LIST, - NULL, NULL, - NULL, NULL, - (X509V3_EXT_I2R)i2r_SCT_LIST, NULL, - NULL }, + [0] = { + .ext_nid = NID_ct_precert_scts, + .ext_flags = 0, + .it = NULL, + .ext_new = NULL, + .ext_free = (X509V3_EXT_FREE)SCT_LIST_free, + .d2i = (X509V3_EXT_D2I)x509_ext_d2i_SCT_LIST, + .i2d = (X509V3_EXT_I2D)i2d_SCT_LIST, + .i2s = NULL, + .s2i = NULL, + .i2v = NULL, + .v2i = NULL, + .i2r = (X509V3_EXT_I2R)i2r_SCT_LIST, + .r2i = NULL, + .usr_data = NULL, + }, /* X509v3 extension to mark a certificate as a pre-certificate */ - { NID_ct_precert_poison, 0, &ASN1_NULL_it, - NULL, NULL, NULL, NULL, - i2s_poison, s2i_poison, - NULL, NULL, - NULL, NULL, - NULL }, + [1] = { + .ext_nid = NID_ct_precert_poison, + .ext_flags = 0, + .it = &ASN1_NULL_it, + .ext_new = NULL, + .ext_free = NULL, + .d2i = NULL, + .i2d = NULL, + .i2s = i2s_poison, + .s2i = s2i_poison, + .i2v = NULL, + .v2i = NULL, + .i2r = NULL, + .r2i = NULL, + .usr_data = NULL, + }, /* OCSP extension that contains SCTs */ - { NID_ct_cert_scts, 0, NULL, - 0, (X509V3_EXT_FREE)SCT_LIST_free, - (X509V3_EXT_D2I)ocsp_ext_d2i_SCT_LIST, (X509V3_EXT_I2D)i2d_SCT_LIST, - NULL, NULL, - NULL, NULL, - (X509V3_EXT_I2R)i2r_SCT_LIST, NULL, - NULL }, + [2] = { + .ext_nid = NID_ct_cert_scts, + .ext_flags = 0, + .it = NULL, + .ext_new = NULL, + .ext_free = (X509V3_EXT_FREE)SCT_LIST_free, + .d2i = (X509V3_EXT_D2I)ocsp_ext_d2i_SCT_LIST, + .i2d = (X509V3_EXT_I2D)i2d_SCT_LIST, + .i2s = NULL, + .s2i = NULL, + .i2v = NULL, + .v2i = NULL, + .i2r = (X509V3_EXT_I2R)i2r_SCT_LIST, + .r2i = NULL, + .usr_data = NULL, + }, }; diff --git a/lib/libcrypto/x509/x509_addr.c b/lib/libcrypto/x509/x509_addr.c index db9ea089f67..418bddf8b19 100644 --- a/lib/libcrypto/x509/x509_addr.c +++ b/lib/libcrypto/x509/x509_addr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_addr.c,v 1.25 2021/12/24 10:09:44 tb Exp $ */ +/* $OpenBSD: x509_addr.c,v 1.26 2021/12/25 15:42:32 tb Exp $ */ /* * Contributed to the OpenSSL Project by the American Registry for * Internet Numbers ("ARIN"). @@ -1366,17 +1366,20 @@ v2i_IPAddrBlocks(const struct v3_ext_method *method, struct v3_ext_ctx *ctx, * OpenSSL dispatch */ const X509V3_EXT_METHOD v3_addr = { - NID_sbgp_ipAddrBlock, /* nid */ - 0, /* flags */ - &IPAddrBlocks_it, - 0, 0, 0, 0, /* old functions, ignored */ - 0, /* i2s */ - 0, /* s2i */ - 0, /* i2v */ - v2i_IPAddrBlocks, /* v2i */ - i2r_IPAddrBlocks, /* i2r */ - 0, /* r2i */ - NULL /* extension-specific data */ + .ext_nid = NID_sbgp_ipAddrBlock, + .ext_flags = 0, + .it = &IPAddrBlocks_it, + .ext_new = NULL, + .ext_free = NULL, + .d2i = NULL, + .i2d = NULL, + .i2s = NULL, + .s2i = NULL, + .i2v = NULL, + .v2i = v2i_IPAddrBlocks, + .i2r = i2r_IPAddrBlocks, + .r2i = NULL, + .usr_data = NULL, }; /* diff --git a/lib/libcrypto/x509/x509_asid.c b/lib/libcrypto/x509/x509_asid.c index 2b4f09d6e63..648f1857487 100644 --- a/lib/libcrypto/x509/x509_asid.c +++ b/lib/libcrypto/x509/x509_asid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_asid.c,v 1.28 2021/12/24 02:30:15 tb Exp $ */ +/* $OpenBSD: x509_asid.c,v 1.29 2021/12/25 15:42:32 tb Exp $ */ /* * Contributed to the OpenSSL Project by the American Registry for * Internet Numbers ("ARIN"). @@ -879,17 +879,20 @@ v2i_ASIdentifiers(const struct v3_ext_method *method, struct v3_ext_ctx *ctx, * OpenSSL dispatch. */ const X509V3_EXT_METHOD v3_asid = { - NID_sbgp_autonomousSysNum, /* nid */ - 0, /* flags */ - &ASIdentifiers_it, /* template */ - 0, 0, 0, 0, /* old functions, ignored */ - 0, /* i2s */ - 0, /* s2i */ - 0, /* i2v */ - v2i_ASIdentifiers, /* v2i */ - i2r_ASIdentifiers, /* i2r */ - 0, /* r2i */ - NULL /* extension-specific data */ + .ext_nid = NID_sbgp_autonomousSysNum, + .ext_flags = 0, + .it = &ASIdentifiers_it, + .ext_new = NULL, + .ext_free = NULL, + .d2i = NULL, + .i2d = NULL, + .i2s = NULL, + .s2i = NULL, + .i2v = NULL, + .v2i = v2i_ASIdentifiers, + .i2r = i2r_ASIdentifiers, + .r2i = NULL, + .usr_data = NULL, }; /* -- 2.20.1