• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
2  * All rights reserved.
3  *
4  * This package is an SSL implementation written
5  * by Eric Young (eay@cryptsoft.com).
6  * The implementation was written so as to conform with Netscapes SSL.
7  *
8  * This library is free for commercial and non-commercial use as long as
9  * the following conditions are aheared to.  The following conditions
10  * apply to all code found in this distribution, be it the RC4, RSA,
11  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
12  * included with this distribution is covered by the same copyright terms
13  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
14  *
15  * Copyright remains Eric Young's, and as such any Copyright notices in
16  * the code are not to be removed.
17  * If this package is used in a product, Eric Young should be given attribution
18  * as the author of the parts of the library used.
19  * This can be in the form of a textual message at program startup or
20  * in documentation (online or textual) provided with the package.
21  *
22  * Redistribution and use in source and binary forms, with or without
23  * modification, are permitted provided that the following conditions
24  * are met:
25  * 1. Redistributions of source code must retain the copyright
26  *    notice, this list of conditions and the following disclaimer.
27  * 2. Redistributions in binary form must reproduce the above copyright
28  *    notice, this list of conditions and the following disclaimer in the
29  *    documentation and/or other materials provided with the distribution.
30  * 3. All advertising materials mentioning features or use of this software
31  *    must display the following acknowledgement:
32  *    "This product includes cryptographic software written by
33  *     Eric Young (eay@cryptsoft.com)"
34  *    The word 'cryptographic' can be left out if the rouines from the library
35  *    being used are not cryptographic related :-).
36  * 4. If you include any Windows specific code (or a derivative thereof) from
37  *    the apps directory (application code) you must include an acknowledgement:
38  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
39  *
40  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
41  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
44  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50  * SUCH DAMAGE.
51  *
52  * The licence and distribution terms for any publically available version or
53  * derivative of this code cannot be changed.  i.e. this code cannot simply be
54  * copied and put under another distribution licence
55  * [including the GNU Public Licence.] */
56 
57 #include <openssl/asn1.h>
58 #include <openssl/evp.h>
59 #include <openssl/obj.h>
60 #include <openssl/stack.h>
61 #include <openssl/x509.h>
62 #include <openssl/x509v3.h>
63 
64 #include "internal.h"
65 
X509_CRL_get_ext_count(const X509_CRL * x)66 int X509_CRL_get_ext_count(const X509_CRL *x) {
67   return (X509v3_get_ext_count(x->crl->extensions));
68 }
69 
X509_CRL_get_ext_by_NID(const X509_CRL * x,int nid,int lastpos)70 int X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid, int lastpos) {
71   return (X509v3_get_ext_by_NID(x->crl->extensions, nid, lastpos));
72 }
73 
X509_CRL_get_ext_by_OBJ(const X509_CRL * x,const ASN1_OBJECT * obj,int lastpos)74 int X509_CRL_get_ext_by_OBJ(const X509_CRL *x, const ASN1_OBJECT *obj,
75                             int lastpos) {
76   return (X509v3_get_ext_by_OBJ(x->crl->extensions, obj, lastpos));
77 }
78 
X509_CRL_get_ext_by_critical(const X509_CRL * x,int crit,int lastpos)79 int X509_CRL_get_ext_by_critical(const X509_CRL *x, int crit, int lastpos) {
80   return (X509v3_get_ext_by_critical(x->crl->extensions, crit, lastpos));
81 }
82 
X509_CRL_get_ext(const X509_CRL * x,int loc)83 X509_EXTENSION *X509_CRL_get_ext(const X509_CRL *x, int loc) {
84   return (X509v3_get_ext(x->crl->extensions, loc));
85 }
86 
X509_CRL_delete_ext(X509_CRL * x,int loc)87 X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc) {
88   return (X509v3_delete_ext(x->crl->extensions, loc));
89 }
90 
X509_CRL_get_ext_d2i(const X509_CRL * crl,int nid,int * out_critical,int * out_idx)91 void *X509_CRL_get_ext_d2i(const X509_CRL *crl, int nid, int *out_critical,
92                            int *out_idx) {
93   return X509V3_get_d2i(crl->crl->extensions, nid, out_critical, out_idx);
94 }
95 
X509_CRL_add1_ext_i2d(X509_CRL * x,int nid,void * value,int crit,unsigned long flags)96 int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,
97                           unsigned long flags) {
98   return X509V3_add1_i2d(&x->crl->extensions, nid, value, crit, flags);
99 }
100 
X509_CRL_add_ext(X509_CRL * x,const X509_EXTENSION * ex,int loc)101 int X509_CRL_add_ext(X509_CRL *x, const X509_EXTENSION *ex, int loc) {
102   return (X509v3_add_ext(&(x->crl->extensions), ex, loc) != NULL);
103 }
104 
X509_get_ext_count(const X509 * x)105 int X509_get_ext_count(const X509 *x) {
106   return (X509v3_get_ext_count(x->cert_info->extensions));
107 }
108 
X509_get_ext_by_NID(const X509 * x,int nid,int lastpos)109 int X509_get_ext_by_NID(const X509 *x, int nid, int lastpos) {
110   return (X509v3_get_ext_by_NID(x->cert_info->extensions, nid, lastpos));
111 }
112 
X509_get_ext_by_OBJ(const X509 * x,const ASN1_OBJECT * obj,int lastpos)113 int X509_get_ext_by_OBJ(const X509 *x, const ASN1_OBJECT *obj, int lastpos) {
114   return (X509v3_get_ext_by_OBJ(x->cert_info->extensions, obj, lastpos));
115 }
116 
X509_get_ext_by_critical(const X509 * x,int crit,int lastpos)117 int X509_get_ext_by_critical(const X509 *x, int crit, int lastpos) {
118   return (X509v3_get_ext_by_critical(x->cert_info->extensions, crit, lastpos));
119 }
120 
X509_get_ext(const X509 * x,int loc)121 X509_EXTENSION *X509_get_ext(const X509 *x, int loc) {
122   return (X509v3_get_ext(x->cert_info->extensions, loc));
123 }
124 
X509_delete_ext(X509 * x,int loc)125 X509_EXTENSION *X509_delete_ext(X509 *x, int loc) {
126   return (X509v3_delete_ext(x->cert_info->extensions, loc));
127 }
128 
X509_add_ext(X509 * x,const X509_EXTENSION * ex,int loc)129 int X509_add_ext(X509 *x, const X509_EXTENSION *ex, int loc) {
130   return (X509v3_add_ext(&(x->cert_info->extensions), ex, loc) != NULL);
131 }
132 
X509_get_ext_d2i(const X509 * x509,int nid,int * out_critical,int * out_idx)133 void *X509_get_ext_d2i(const X509 *x509, int nid, int *out_critical,
134                        int *out_idx) {
135   return X509V3_get_d2i(x509->cert_info->extensions, nid, out_critical,
136                         out_idx);
137 }
138 
X509_add1_ext_i2d(X509 * x,int nid,void * value,int crit,unsigned long flags)139 int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,
140                       unsigned long flags) {
141   return X509V3_add1_i2d(&x->cert_info->extensions, nid, value, crit, flags);
142 }
143 
X509_REVOKED_get_ext_count(const X509_REVOKED * x)144 int X509_REVOKED_get_ext_count(const X509_REVOKED *x) {
145   return (X509v3_get_ext_count(x->extensions));
146 }
147 
X509_REVOKED_get_ext_by_NID(const X509_REVOKED * x,int nid,int lastpos)148 int X509_REVOKED_get_ext_by_NID(const X509_REVOKED *x, int nid, int lastpos) {
149   return (X509v3_get_ext_by_NID(x->extensions, nid, lastpos));
150 }
151 
X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED * x,const ASN1_OBJECT * obj,int lastpos)152 int X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x, const ASN1_OBJECT *obj,
153                                 int lastpos) {
154   return (X509v3_get_ext_by_OBJ(x->extensions, obj, lastpos));
155 }
156 
X509_REVOKED_get_ext_by_critical(const X509_REVOKED * x,int crit,int lastpos)157 int X509_REVOKED_get_ext_by_critical(const X509_REVOKED *x, int crit,
158                                      int lastpos) {
159   return (X509v3_get_ext_by_critical(x->extensions, crit, lastpos));
160 }
161 
X509_REVOKED_get_ext(const X509_REVOKED * x,int loc)162 X509_EXTENSION *X509_REVOKED_get_ext(const X509_REVOKED *x, int loc) {
163   return (X509v3_get_ext(x->extensions, loc));
164 }
165 
X509_REVOKED_delete_ext(X509_REVOKED * x,int loc)166 X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc) {
167   return (X509v3_delete_ext(x->extensions, loc));
168 }
169 
X509_REVOKED_add_ext(X509_REVOKED * x,const X509_EXTENSION * ex,int loc)170 int X509_REVOKED_add_ext(X509_REVOKED *x, const X509_EXTENSION *ex, int loc) {
171   return (X509v3_add_ext(&(x->extensions), ex, loc) != NULL);
172 }
173 
X509_REVOKED_get_ext_d2i(const X509_REVOKED * revoked,int nid,int * out_critical,int * out_idx)174 void *X509_REVOKED_get_ext_d2i(const X509_REVOKED *revoked, int nid,
175                                int *out_critical, int *out_idx) {
176   return X509V3_get_d2i(revoked->extensions, nid, out_critical, out_idx);
177 }
178 
X509_REVOKED_add1_ext_i2d(X509_REVOKED * x,int nid,void * value,int crit,unsigned long flags)179 int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,
180                               unsigned long flags) {
181   return X509V3_add1_i2d(&x->extensions, nid, value, crit, flags);
182 }
183