Move the CRL reason method into x509_bitst.c
authortb <tb@openbsd.org>
Fri, 21 Apr 2023 06:11:56 +0000 (06:11 +0000)
committertb <tb@openbsd.org>
Fri, 21 Apr 2023 06:11:56 +0000 (06:11 +0000)
The CRL extension handler is completely misplaced in x509_enum.c.
Move it to x509_bitst.c until we find a better home for it. This
way it is next to the other two extension methods that have the
extra usr_data contortion.

lib/libcrypto/x509/x509_bitst.c
lib/libcrypto/x509/x509_enum.c

index cacbe8e..97c630d 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509_bitst.c,v 1.3 2023/02/16 08:38:17 tb Exp $ */
+/* $OpenBSD: x509_bitst.c,v 1.4 2023/04/21 06:11:56 tb Exp $ */
 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
  * project 1999.
  */
@@ -88,6 +88,20 @@ static BIT_STRING_BITNAME key_usage_type_table[] = {
        {-1, NULL, NULL}
 };
 
+static BIT_STRING_BITNAME crl_reasons[] = {
+       {CRL_REASON_UNSPECIFIED,         "Unspecified", "unspecified"},
+       {CRL_REASON_KEY_COMPROMISE,      "Key Compromise", "keyCompromise"},
+       {CRL_REASON_CA_COMPROMISE,       "CA Compromise", "CACompromise"},
+       {CRL_REASON_AFFILIATION_CHANGED, "Affiliation Changed", "affiliationChanged"},
+       {CRL_REASON_SUPERSEDED,          "Superseded", "superseded"},
+       {CRL_REASON_CESSATION_OF_OPERATION, "Cessation Of Operation", "cessationOfOperation"},
+       {CRL_REASON_CERTIFICATE_HOLD,    "Certificate Hold", "certificateHold"},
+       {CRL_REASON_REMOVE_FROM_CRL,     "Remove From CRL", "removeFromCRL"},
+       {CRL_REASON_PRIVILEGE_WITHDRAWN, "Privilege Withdrawn", "privilegeWithdrawn"},
+       {CRL_REASON_AA_COMPROMISE,       "AA Compromise", "AACompromise"},
+       {-1, NULL, NULL}
+};
+
 const X509V3_EXT_METHOD v3_nscert = {
        .ext_nid = NID_netscape_cert_type,
        .ext_flags = 0,
@@ -122,6 +136,23 @@ const X509V3_EXT_METHOD v3_key_usage = {
        .usr_data = key_usage_type_table,
 };
 
+const X509V3_EXT_METHOD v3_crl_reason = {
+       .ext_nid = NID_crl_reason,
+       .ext_flags = 0,
+       .it = &ASN1_ENUMERATED_it,
+       .ext_new = NULL,
+       .ext_free = NULL,
+       .d2i = NULL,
+       .i2d = NULL,
+       .i2s = (X509V3_EXT_I2S)i2s_ASN1_ENUMERATED_TABLE,
+       .s2i = NULL,
+       .i2v = NULL,
+       .v2i = NULL,
+       .i2r = NULL,
+       .r2i = NULL,
+       .usr_data = crl_reasons,
+};
+
 STACK_OF(CONF_VALUE) *
 i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, ASN1_BIT_STRING *bits,
     STACK_OF(CONF_VALUE) *ret)
index 0f3bfea..9e8a291 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509_enum.c,v 1.6 2023/04/21 06:07:10 tb Exp $ */
+/* $OpenBSD: x509_enum.c,v 1.7 2023/04/21 06:11:56 tb Exp $ */
 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
  * project 1999.
  */
 
 #include <openssl/asn1.h>
 #include <openssl/x509v3.h>
-
-static BIT_STRING_BITNAME crl_reasons[] = {
-       {CRL_REASON_UNSPECIFIED,         "Unspecified", "unspecified"},
-       {CRL_REASON_KEY_COMPROMISE,      "Key Compromise", "keyCompromise"},
-       {CRL_REASON_CA_COMPROMISE,       "CA Compromise", "CACompromise"},
-       {CRL_REASON_AFFILIATION_CHANGED, "Affiliation Changed", "affiliationChanged"},
-       {CRL_REASON_SUPERSEDED,          "Superseded", "superseded"},
-       {CRL_REASON_CESSATION_OF_OPERATION, "Cessation Of Operation", "cessationOfOperation"},
-       {CRL_REASON_CERTIFICATE_HOLD,    "Certificate Hold", "certificateHold"},
-       {CRL_REASON_REMOVE_FROM_CRL,     "Remove From CRL", "removeFromCRL"},
-       {CRL_REASON_PRIVILEGE_WITHDRAWN, "Privilege Withdrawn", "privilegeWithdrawn"},
-       {CRL_REASON_AA_COMPROMISE,       "AA Compromise", "AACompromise"},
-       {-1, NULL, NULL}
-};
-
-const X509V3_EXT_METHOD v3_crl_reason = {
-       .ext_nid = NID_crl_reason,
-       .ext_flags = 0,
-       .it = &ASN1_ENUMERATED_it,
-       .ext_new = NULL,
-       .ext_free = NULL,
-       .d2i = NULL,
-       .i2d = NULL,
-       .i2s = (X509V3_EXT_I2S)i2s_ASN1_ENUMERATED_TABLE,
-       .s2i = NULL,
-       .i2v = NULL,
-       .v2i = NULL,
-       .i2r = NULL,
-       .r2i = NULL,
-       .usr_data = crl_reasons,
-};