| 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 "ext_dat.h" |
| 23 | #include "internal.h" |
| 24 |
| 25 |
| 26 | typedef BIT_STRING_BITNAME ENUMERATED_NAMES; |
| 27 |
| 28 | static const ENUMERATED_NAMES crl_reasons[] = { |
| 29 | {CRL_REASON_UNSPECIFIED, "Unspecified", "unspecified"}, |
| 30 | {CRL_REASON_KEY_COMPROMISE, "Key Compromise", "keyCompromise"}, |
| 31 | {CRL_REASON_CA_COMPROMISE, "CA Compromise", "CACompromise"}, |
| 32 | {CRL_REASON_AFFILIATION_CHANGED, "Affiliation Changed", |
| 33 | "affiliationChanged"}, |
| 34 | {CRL_REASON_SUPERSEDED, "Superseded", "superseded"}, |
| 35 | {CRL_REASON_CESSATION_OF_OPERATION, "Cessation Of Operation", |
| 36 | "cessationOfOperation"}, |
| 37 | {CRL_REASON_CERTIFICATE_HOLD, "Certificate Hold", "certificateHold"}, |
| 38 | {CRL_REASON_REMOVE_FROM_CRL, "Remove From CRL", "removeFromCRL"}, |
| 39 | {CRL_REASON_PRIVILEGE_WITHDRAWN, "Privilege Withdrawn", |
| 40 | "privilegeWithdrawn"}, |
| 41 | {CRL_REASON_AA_COMPROMISE, "AA Compromise", "AACompromise"}, |
| 42 | {-1, NULL, NULL}}; |
| 43 |
| 44 | static char *i2s_ASN1_ENUMERATED_TABLE(const X509V3_EXT_METHOD *method, |
| 45 | void *ext) { |
| 46 | const ASN1_ENUMERATED *e = reinterpret_cast<const ASN1_ENUMERATED *>(ext); |
| 47 | long strval = ASN1_ENUMERATED_get(e); |
| 48 | for (const ENUMERATED_NAMES *enam = |
| 49 | reinterpret_cast<const ENUMERATED_NAMES *>(method->usr_data); |
| 50 | enam->lname; enam++) { |
| 51 | if (strval == enam->bitnum) { |
| 52 | return OPENSSL_strdup(enam->lname); |
| 53 | } |
| 54 | } |
| 55 | return i2s_ASN1_ENUMERATED(method, e); |
| 56 | } |
| 57 |
| 58 | const X509V3_EXT_METHOD v3_crl_reason = { |
| 59 | NID_crl_reason, |
| 60 | 0, |
| 61 | ASN1_ITEM_ref(ASN1_ENUMERATED), |
| 62 | 0, |
| 63 | 0, |
| 64 | 0, |
| 65 | 0, |
| 66 | i2s_ASN1_ENUMERATED_TABLE, |
| 67 | 0, |
| 68 | 0, |
| 69 | 0, |
| 70 | 0, |
| 71 | 0, |
| 72 | (void *)crl_reasons, |
| 73 | }; |
| 74 |