| 1 |
// Written by Dr Stephen N Henson ([email protected]) for the OpenSSL project 1999. |
| 2 |
// Copyright (c) 1999 The OpenSSL Project. All rights reserved. |
| 3 |
// SPDX-License-Identifier: Apache-2.0 |
| 4 |
|
| 5 |
#include <stdio.h> |
| 6 |
|
| 7 |
#include <openssl/mem.h> |
| 8 |
#include <openssl/obj.h> |
| 9 |
#include <openssl/x509.h> |
| 10 |
#include <openssl/x509v3.h> |
| 11 |
|
| 12 |
#include "internal.h" |
| 13 |
|
| 14 |
|
| 15 |
typedef BIT_STRING_BITNAME ENUMERATED_NAMES; |
| 16 |
|
| 17 |
static const ENUMERATED_NAMES crl_reasons[] = { |
| 18 |
{CRL_REASON_UNSPECIFIED, "Unspecified", "unspecified"}, |
| 19 |
{CRL_REASON_KEY_COMPROMISE, "Key Compromise", "keyCompromise"}, |
| 20 |
{CRL_REASON_CA_COMPROMISE, "CA Compromise", "CACompromise"}, |
| 21 |
{CRL_REASON_AFFILIATION_CHANGED, "Affiliation Changed", |
| 22 |
"affiliationChanged"}, |
| 23 |
{CRL_REASON_SUPERSEDED, "Superseded", "superseded"}, |
| 24 |
{CRL_REASON_CESSATION_OF_OPERATION, "Cessation Of Operation", |
| 25 |
"cessationOfOperation"}, |
| 26 |
{CRL_REASON_CERTIFICATE_HOLD, "Certificate Hold", "certificateHold"}, |
| 27 |
{CRL_REASON_REMOVE_FROM_CRL, "Remove From CRL", "removeFromCRL"}, |
| 28 |
{CRL_REASON_PRIVILEGE_WITHDRAWN, "Privilege Withdrawn", |
| 29 |
"privilegeWithdrawn"}, |
| 30 |
{CRL_REASON_AA_COMPROMISE, "AA Compromise", "AACompromise"}, |
| 31 |
{-1, NULL, NULL}}; |
| 32 |
|
| 33 |
static char *i2s_ASN1_ENUMERATED_TABLE(const X509V3_EXT_METHOD *method, |
| 34 |
void *ext) { |
| 35 |
const ASN1_ENUMERATED *e = ext; |
| 36 |
long strval = ASN1_ENUMERATED_get(e); |
| 37 |
for (const ENUMERATED_NAMES *enam = method->usr_data; enam->lname; enam++) { |
| 38 |
if (strval == enam->bitnum) { |
| 39 |
return OPENSSL_strdup(enam->lname); |
| 40 |
} |
| 41 |
} |
| 42 |
return i2s_ASN1_ENUMERATED(method, e); |
| 43 |
} |
| 44 |
|
| 45 |
const X509V3_EXT_METHOD v3_crl_reason = { |
| 46 |
NID_crl_reason, |
| 47 |
0, |
| 48 |
ASN1_ITEM_ref(ASN1_ENUMERATED), |
| 49 |
0, |
| 50 |
0, |
| 51 |
0, |
| 52 |
0, |
| 53 |
i2s_ASN1_ENUMERATED_TABLE, |
| 54 |
0, |
| 55 |
0, |
| 56 |
0, |
| 57 |
0, |
| 58 |
0, |
| 59 |
(void *)crl_reasons, |
| 60 |
}; |