v3_enum.c revision 296465
181084Sjake/* v3_enum.c */
281084Sjake/*
381084Sjake * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
481084Sjake * 1999.
581084Sjake */
681084Sjake/* ====================================================================
781084Sjake * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
881084Sjake *
981084Sjake * Redistribution and use in source and binary forms, with or without
10147272Smarius * modification, are permitted provided that the following conditions
11147272Smarius * are met:
12147272Smarius *
13147272Smarius * 1. Redistributions of source code must retain the above copyright
14147272Smarius *    notice, this list of conditions and the following disclaimer.
15146419Smarius *
16146419Smarius * 2. Redistributions in binary form must reproduce the above copyright
17146419Smarius *    notice, this list of conditions and the following disclaimer in
18146419Smarius *    the documentation and/or other materials provided with the
19146419Smarius *    distribution.
20146419Smarius *
21147307Smarcel * 3. All advertising materials mentioning features or use of this
2291671Sume *    software must display the following acknowledgment:
23147307Smarcel *    "This product includes software developed by the OpenSSL Project
2491671Sume *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25147307Smarcel *
26147272Smarius * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27147272Smarius *    endorse or promote products derived from this software without
28147272Smarius *    prior written permission. For written permission, please contact
29147272Smarius *    licensing@OpenSSL.org.
30147272Smarius *
31147272Smarius * 5. Products derived from this software may not be called "OpenSSL"
32147272Smarius *    nor may "OpenSSL" appear in their names without prior written
33136301Syongari *    permission of the OpenSSL Project.
34136301Syongari *
35130294Sscottl * 6. Redistributions of any form whatsoever must retain the following
36119382Sjake *    acknowledgment:
37119382Sjake *    "This product includes software developed by the OpenSSL Project
38146483Smarius *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39119382Sjake *
40147191Sjkoshy * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41147272Smarius * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42119382Sjake * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43146419Smarius * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
44133589Smarius * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4590623Stmm * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
4686148Stmm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47105399Stmm * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48116584Sjake * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49151805Sjoerg * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50151805Sjoerg * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51136944Syongari * OF THE POSSIBILITY OF SUCH DAMAGE.
52136944Syongari * ====================================================================
53119382Sjake *
54119382Sjake * This product includes cryptographic software written by Eric Young
55119382Sjake * (eay@cryptsoft.com).  This product includes software written by Tim
56119382Sjake * Hudson (tjh@cryptsoft.com).
57119382Sjake *
58119382Sjake */
59119382Sjake
60119382Sjake#include <stdio.h>
61119382Sjake#include "cryptlib.h"
62119382Sjake#include <openssl/x509v3.h>
63119816Smarcel
64122470Sjakestatic ENUMERATED_NAMES crl_reasons[] = {
65104519Sphk    {0, "Unspecified", "unspecified"},
66113591Sphk    {1, "Key Compromise", "keyCompromise"},
67104519Sphk    {2, "CA Compromise", "CACompromise"},
68113819Sphk    {3, "Affiliation Changed", "affiliationChanged"},
6993122Stmm    {4, "Superseded", "superseded"},
70124516Sdes    {5, "Cessation Of Operation", "cessationOfOperation"},
71124481Sdes    {6, "Certificate Hold", "certificateHold"},
72124481Sdes    {8, "Remove From CRL", "removeFromCRL"},
73124481Sdes    {-1, NULL, NULL}
74111072Sjake};
75119382Sjake
76100399Speterconst X509V3_EXT_METHOD v3_crl_reason = {
77143827Smarius    NID_crl_reason, 0, ASN1_ITEM_ref(ASN1_ENUMERATED),
78111072Sjake    0, 0, 0, 0,
79111072Sjake    (X509V3_EXT_I2S)i2s_ASN1_ENUMERATED_TABLE,
80111072Sjake    0,
8186235Stmm    0, 0, 0, 0,
82136944Syongari    crl_reasons
83141754Smarius};
84141754Smarius
85128758Smariuschar *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *method, ASN1_ENUMERATED *e)
8686235Stmm{
87129051Smarius    ENUMERATED_NAMES *enam;
88129051Smarius    long strval;
89129051Smarius    strval = ASN1_ENUMERATED_get(e);
90141754Smarius    for (enam = method->usr_data; enam->lname; enam++) {
9186235Stmm        if (strval == enam->bitnum)
92146392Smarius            return BUF_strdup(enam->lname);
9390623Stmm    }
94146392Smarius    return i2s_ASN1_ENUMERATED(method, e);
9581084Sjake}
9686235Stmm