summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/x509v3/v3_ocsp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/x509v3/v3_ocsp.c')
-rw-r--r--src/lib/libcrypto/x509v3/v3_ocsp.c327
1 files changed, 0 insertions, 327 deletions
diff --git a/src/lib/libcrypto/x509v3/v3_ocsp.c b/src/lib/libcrypto/x509v3/v3_ocsp.c
deleted file mode 100644
index 1d9c8a8513..0000000000
--- a/src/lib/libcrypto/x509v3/v3_ocsp.c
+++ /dev/null
@@ -1,327 +0,0 @@
1/* $OpenBSD: v3_ocsp.c,v 1.11 2015/02/15 08:45:27 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <stdio.h>
60#include <string.h>
61
62#include <openssl/opensslconf.h>
63
64#ifndef OPENSSL_NO_OCSP
65
66#include <openssl/asn1.h>
67#include <openssl/conf.h>
68#include <openssl/err.h>
69#include <openssl/ocsp.h>
70#include <openssl/x509v3.h>
71
72/* OCSP extensions and a couple of CRL entry extensions
73 */
74
75static int i2r_ocsp_crlid(const X509V3_EXT_METHOD *method, void *nonce,
76 BIO *out, int indent);
77static int i2r_ocsp_acutoff(const X509V3_EXT_METHOD *method, void *nonce,
78 BIO *out, int indent);
79static int i2r_object(const X509V3_EXT_METHOD *method, void *obj, BIO *out,
80 int indent);
81
82static void *ocsp_nonce_new(void);
83static int i2d_ocsp_nonce(void *a, unsigned char **pp);
84static void *d2i_ocsp_nonce(void *a, const unsigned char **pp, long length);
85static void ocsp_nonce_free(void *a);
86static int i2r_ocsp_nonce(const X509V3_EXT_METHOD *method, void *nonce,
87 BIO *out, int indent);
88
89static int i2r_ocsp_nocheck(const X509V3_EXT_METHOD *method,
90 void *nocheck, BIO *out, int indent);
91static void *s2i_ocsp_nocheck(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
92 const char *str);
93static int i2r_ocsp_serviceloc(const X509V3_EXT_METHOD *method, void *in,
94 BIO *bp, int ind);
95
96const X509V3_EXT_METHOD v3_ocsp_crlid = {
97 NID_id_pkix_OCSP_CrlID, 0, ASN1_ITEM_ref(OCSP_CRLID),
98 0, 0, 0, 0,
99 0, 0,
100 0, 0,
101 i2r_ocsp_crlid, 0,
102 NULL
103};
104
105const X509V3_EXT_METHOD v3_ocsp_acutoff = {
106 NID_id_pkix_OCSP_archiveCutoff, 0, ASN1_ITEM_ref(ASN1_GENERALIZEDTIME),
107 0, 0, 0, 0,
108 0, 0,
109 0, 0,
110 i2r_ocsp_acutoff, 0,
111 NULL
112};
113
114const X509V3_EXT_METHOD v3_crl_invdate = {
115 NID_invalidity_date, 0, ASN1_ITEM_ref(ASN1_GENERALIZEDTIME),
116 0, 0, 0, 0,
117 0, 0,
118 0, 0,
119 i2r_ocsp_acutoff, 0,
120 NULL
121};
122
123const X509V3_EXT_METHOD v3_crl_hold = {
124 NID_hold_instruction_code, 0, ASN1_ITEM_ref(ASN1_OBJECT),
125 0, 0, 0, 0,
126 0, 0,
127 0, 0,
128 i2r_object, 0,
129 NULL
130};
131
132const X509V3_EXT_METHOD v3_ocsp_nonce = {
133 NID_id_pkix_OCSP_Nonce, 0, NULL,
134 ocsp_nonce_new,
135 ocsp_nonce_free,
136 d2i_ocsp_nonce,
137 i2d_ocsp_nonce,
138 0, 0,
139 0, 0,
140 i2r_ocsp_nonce, 0,
141 NULL
142};
143
144const X509V3_EXT_METHOD v3_ocsp_nocheck = {
145 NID_id_pkix_OCSP_noCheck, 0, ASN1_ITEM_ref(ASN1_NULL),
146 0, 0, 0, 0,
147 0, s2i_ocsp_nocheck,
148 0, 0,
149 i2r_ocsp_nocheck, 0,
150 NULL
151};
152
153const X509V3_EXT_METHOD v3_ocsp_serviceloc = {
154 NID_id_pkix_OCSP_serviceLocator, 0, ASN1_ITEM_ref(OCSP_SERVICELOC),
155 0, 0, 0, 0,
156 0, 0,
157 0, 0,
158 i2r_ocsp_serviceloc, 0,
159 NULL
160};
161
162static int
163i2r_ocsp_crlid(const X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind)
164{
165 OCSP_CRLID *a = in;
166 if (a->crlUrl) {
167 if (BIO_printf(bp, "%*scrlUrl: ", ind, "") <= 0)
168 goto err;
169 if (!ASN1_STRING_print(bp, (ASN1_STRING*)a->crlUrl))
170 goto err;
171 if (BIO_write(bp, "\n", 1) <= 0)
172 goto err;
173 }
174 if (a->crlNum) {
175 if (BIO_printf(bp, "%*scrlNum: ", ind, "") <= 0)
176 goto err;
177 if (i2a_ASN1_INTEGER(bp, a->crlNum) <= 0)
178 goto err;
179 if (BIO_write(bp, "\n", 1) <= 0)
180 goto err;
181 }
182 if (a->crlTime) {
183 if (BIO_printf(bp, "%*scrlTime: ", ind, "") <= 0)
184 goto err;
185 if (!ASN1_GENERALIZEDTIME_print(bp, a->crlTime))
186 goto err;
187 if (BIO_write(bp, "\n", 1) <= 0)
188 goto err;
189 }
190 return 1;
191
192err:
193 return 0;
194}
195
196static int
197i2r_ocsp_acutoff(const X509V3_EXT_METHOD *method, void *cutoff, BIO *bp,
198 int ind)
199{
200 if (BIO_printf(bp, "%*s", ind, "") <= 0)
201 return 0;
202 if (!ASN1_GENERALIZEDTIME_print(bp, cutoff))
203 return 0;
204 return 1;
205}
206
207static int
208i2r_object(const X509V3_EXT_METHOD *method, void *oid, BIO *bp, int ind)
209{
210 if (BIO_printf(bp, "%*s", ind, "") <= 0)
211 return 0;
212 if (i2a_ASN1_OBJECT(bp, oid) <= 0)
213 return 0;
214 return 1;
215}
216
217/* OCSP nonce. This is needs special treatment because it doesn't have
218 * an ASN1 encoding at all: it just contains arbitrary data.
219 */
220
221static void *
222ocsp_nonce_new(void)
223{
224 return ASN1_OCTET_STRING_new();
225}
226
227static int
228i2d_ocsp_nonce(void *a, unsigned char **pp)
229{
230 ASN1_OCTET_STRING *os = a;
231
232 if (pp) {
233 memcpy(*pp, os->data, os->length);
234 *pp += os->length;
235 }
236 return os->length;
237}
238
239static void *
240d2i_ocsp_nonce(void *a, const unsigned char **pp, long length)
241{
242 ASN1_OCTET_STRING *os, **pos;
243
244 pos = a;
245 if (pos == NULL || *pos == NULL) {
246 os = ASN1_OCTET_STRING_new();
247 if (os == NULL)
248 goto err;
249 } else
250 os = *pos;
251 if (ASN1_OCTET_STRING_set(os, *pp, length) == 0)
252 goto err;
253
254 *pp += length;
255
256 if (pos != NULL)
257 *pos = os;
258 return os;
259
260err:
261 if (pos == NULL || *pos != os)
262 M_ASN1_OCTET_STRING_free(os);
263 OCSPerr(OCSP_F_D2I_OCSP_NONCE, ERR_R_MALLOC_FAILURE);
264 return NULL;
265}
266
267static void
268ocsp_nonce_free(void *a)
269{
270 M_ASN1_OCTET_STRING_free(a);
271}
272
273static int
274i2r_ocsp_nonce(const X509V3_EXT_METHOD *method, void *nonce, BIO *out,
275 int indent)
276{
277 if (BIO_printf(out, "%*s", indent, "") <= 0)
278 return 0;
279 if (i2a_ASN1_STRING(out, nonce, V_ASN1_OCTET_STRING) <= 0)
280 return 0;
281 return 1;
282}
283
284/* Nocheck is just a single NULL. Don't print anything and always set it */
285
286static int
287i2r_ocsp_nocheck(const X509V3_EXT_METHOD *method, void *nocheck, BIO *out,
288 int indent)
289{
290 return 1;
291}
292
293static void *
294s2i_ocsp_nocheck(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
295 const char *str)
296{
297 return ASN1_NULL_new();
298}
299
300static int
301i2r_ocsp_serviceloc(const X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind)
302{
303 int i;
304 OCSP_SERVICELOC *a = in;
305 ACCESS_DESCRIPTION *ad;
306
307 if (BIO_printf(bp, "%*sIssuer: ", ind, "") <= 0)
308 goto err;
309 if (X509_NAME_print_ex(bp, a->issuer, 0, XN_FLAG_ONELINE) <= 0)
310 goto err;
311 for (i = 0; i < sk_ACCESS_DESCRIPTION_num(a->locator); i++) {
312 ad = sk_ACCESS_DESCRIPTION_value(a->locator, i);
313 if (BIO_printf(bp, "\n%*s", (2 * ind), "") <= 0)
314 goto err;
315 if (i2a_ASN1_OBJECT(bp, ad->method) <= 0)
316 goto err;
317 if (BIO_puts(bp, " - ") <= 0)
318 goto err;
319 if (GENERAL_NAME_print(bp, ad->location) <= 0)
320 goto err;
321 }
322 return 1;
323
324err:
325 return 0;
326}
327#endif