/src/boringssl/crypto/x509/v3_enum.cc
Line | Count | Source |
1 | | // Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | // you may not use this file except in compliance with the License. |
5 | | // You may obtain a copy of the License at |
6 | | // |
7 | | // https://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | // See the License for the specific language governing permissions and |
13 | | // limitations under the License. |
14 | | |
15 | | #include <stdio.h> |
16 | | |
17 | | #include <openssl/mem.h> |
18 | | #include <openssl/obj.h> |
19 | | #include <openssl/x509.h> |
20 | | #include <openssl/x509v3.h> |
21 | | |
22 | | #include "internal.h" |
23 | | |
24 | | |
25 | | using namespace bssl; |
26 | | |
27 | | typedef BIT_STRING_BITNAME ENUMERATED_NAMES; |
28 | | |
29 | | static const ENUMERATED_NAMES crl_reasons[] = { |
30 | | {CRL_REASON_UNSPECIFIED, "Unspecified", "unspecified"}, |
31 | | {CRL_REASON_KEY_COMPROMISE, "Key Compromise", "keyCompromise"}, |
32 | | {CRL_REASON_CA_COMPROMISE, "CA Compromise", "CACompromise"}, |
33 | | {CRL_REASON_AFFILIATION_CHANGED, "Affiliation Changed", |
34 | | "affiliationChanged"}, |
35 | | {CRL_REASON_SUPERSEDED, "Superseded", "superseded"}, |
36 | | {CRL_REASON_CESSATION_OF_OPERATION, "Cessation Of Operation", |
37 | | "cessationOfOperation"}, |
38 | | {CRL_REASON_CERTIFICATE_HOLD, "Certificate Hold", "certificateHold"}, |
39 | | {CRL_REASON_REMOVE_FROM_CRL, "Remove From CRL", "removeFromCRL"}, |
40 | | {CRL_REASON_PRIVILEGE_WITHDRAWN, "Privilege Withdrawn", |
41 | | "privilegeWithdrawn"}, |
42 | | {CRL_REASON_AA_COMPROMISE, "AA Compromise", "AACompromise"}, |
43 | | {-1, nullptr, nullptr}}; |
44 | | |
45 | | static char *i2s_ASN1_ENUMERATED_TABLE(const X509V3_EXT_METHOD *method, |
46 | 1.06k | void *ext) { |
47 | 1.06k | const ASN1_ENUMERATED *e = reinterpret_cast<const ASN1_ENUMERATED *>(ext); |
48 | 1.06k | long strval = ASN1_ENUMERATED_get(e); |
49 | 1.06k | for (const ENUMERATED_NAMES *enam = |
50 | 1.06k | reinterpret_cast<const ENUMERATED_NAMES *>(method->usr_data); |
51 | 11.1k | enam->lname; enam++) { |
52 | 10.1k | if (strval == enam->bitnum) { |
53 | 57 | return OPENSSL_strdup(enam->lname); |
54 | 57 | } |
55 | 10.1k | } |
56 | 1.00k | return i2s_ASN1_ENUMERATED(method, e); |
57 | 1.06k | } |
58 | | |
59 | | const X509V3_EXT_METHOD bssl::v3_crl_reason = { |
60 | | NID_crl_reason, |
61 | | 0, |
62 | | ASN1_ITEM_ref(ASN1_ENUMERATED), |
63 | | nullptr, |
64 | | nullptr, |
65 | | nullptr, |
66 | | nullptr, |
67 | | i2s_ASN1_ENUMERATED_TABLE, |
68 | | nullptr, |
69 | | nullptr, |
70 | | nullptr, |
71 | | nullptr, |
72 | | nullptr, |
73 | | (void *)crl_reasons, |
74 | | }; |