1*de0e0e4dSAntonio Huete Jimenez /* $OpenBSD: x509_ocsp.c,v 1.2 2022/01/07 09:45:52 tb Exp $ */
28edacedfSDaniel Fojt /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
38edacedfSDaniel Fojt  * project 1999.
48edacedfSDaniel Fojt  */
58edacedfSDaniel Fojt /* ====================================================================
68edacedfSDaniel Fojt  * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
78edacedfSDaniel Fojt  *
88edacedfSDaniel Fojt  * Redistribution and use in source and binary forms, with or without
98edacedfSDaniel Fojt  * modification, are permitted provided that the following conditions
108edacedfSDaniel Fojt  * are met:
118edacedfSDaniel Fojt  *
128edacedfSDaniel Fojt  * 1. Redistributions of source code must retain the above copyright
138edacedfSDaniel Fojt  *    notice, this list of conditions and the following disclaimer.
148edacedfSDaniel Fojt  *
158edacedfSDaniel Fojt  * 2. Redistributions in binary form must reproduce the above copyright
168edacedfSDaniel Fojt  *    notice, this list of conditions and the following disclaimer in
178edacedfSDaniel Fojt  *    the documentation and/or other materials provided with the
188edacedfSDaniel Fojt  *    distribution.
198edacedfSDaniel Fojt  *
208edacedfSDaniel Fojt  * 3. All advertising materials mentioning features or use of this
218edacedfSDaniel Fojt  *    software must display the following acknowledgment:
228edacedfSDaniel Fojt  *    "This product includes software developed by the OpenSSL Project
238edacedfSDaniel Fojt  *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
248edacedfSDaniel Fojt  *
258edacedfSDaniel Fojt  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
268edacedfSDaniel Fojt  *    endorse or promote products derived from this software without
278edacedfSDaniel Fojt  *    prior written permission. For written permission, please contact
288edacedfSDaniel Fojt  *    licensing@OpenSSL.org.
298edacedfSDaniel Fojt  *
308edacedfSDaniel Fojt  * 5. Products derived from this software may not be called "OpenSSL"
318edacedfSDaniel Fojt  *    nor may "OpenSSL" appear in their names without prior written
328edacedfSDaniel Fojt  *    permission of the OpenSSL Project.
338edacedfSDaniel Fojt  *
348edacedfSDaniel Fojt  * 6. Redistributions of any form whatsoever must retain the following
358edacedfSDaniel Fojt  *    acknowledgment:
368edacedfSDaniel Fojt  *    "This product includes software developed by the OpenSSL Project
378edacedfSDaniel Fojt  *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
388edacedfSDaniel Fojt  *
398edacedfSDaniel Fojt  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
408edacedfSDaniel Fojt  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
418edacedfSDaniel Fojt  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
428edacedfSDaniel Fojt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
438edacedfSDaniel Fojt  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
448edacedfSDaniel Fojt  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
458edacedfSDaniel Fojt  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
468edacedfSDaniel Fojt  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
478edacedfSDaniel Fojt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
488edacedfSDaniel Fojt  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
498edacedfSDaniel Fojt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
508edacedfSDaniel Fojt  * OF THE POSSIBILITY OF SUCH DAMAGE.
518edacedfSDaniel Fojt  * ====================================================================
528edacedfSDaniel Fojt  *
538edacedfSDaniel Fojt  * This product includes cryptographic software written by Eric Young
548edacedfSDaniel Fojt  * (eay@cryptsoft.com).  This product includes software written by Tim
558edacedfSDaniel Fojt  * Hudson (tjh@cryptsoft.com).
568edacedfSDaniel Fojt  *
578edacedfSDaniel Fojt  */
588edacedfSDaniel Fojt 
598edacedfSDaniel Fojt #include <stdio.h>
608edacedfSDaniel Fojt #include <string.h>
618edacedfSDaniel Fojt 
628edacedfSDaniel Fojt #include <openssl/opensslconf.h>
638edacedfSDaniel Fojt 
648edacedfSDaniel Fojt #ifndef OPENSSL_NO_OCSP
658edacedfSDaniel Fojt 
668edacedfSDaniel Fojt #include <openssl/asn1.h>
678edacedfSDaniel Fojt #include <openssl/conf.h>
688edacedfSDaniel Fojt #include <openssl/err.h>
698edacedfSDaniel Fojt #include <openssl/ocsp.h>
708edacedfSDaniel Fojt #include <openssl/x509v3.h>
718edacedfSDaniel Fojt 
72*de0e0e4dSAntonio Huete Jimenez #include "ocsp_local.h"
73*de0e0e4dSAntonio Huete Jimenez 
748edacedfSDaniel Fojt /* OCSP extensions and a couple of CRL entry extensions
758edacedfSDaniel Fojt  */
768edacedfSDaniel Fojt 
778edacedfSDaniel Fojt static int i2r_ocsp_crlid(const X509V3_EXT_METHOD *method, void *nonce,
788edacedfSDaniel Fojt     BIO *out, int indent);
798edacedfSDaniel Fojt static int i2r_ocsp_acutoff(const X509V3_EXT_METHOD *method, void *nonce,
808edacedfSDaniel Fojt     BIO *out, int indent);
818edacedfSDaniel Fojt static int i2r_object(const X509V3_EXT_METHOD *method, void *obj, BIO *out,
828edacedfSDaniel Fojt     int indent);
838edacedfSDaniel Fojt 
848edacedfSDaniel Fojt static void *ocsp_nonce_new(void);
858edacedfSDaniel Fojt static int i2d_ocsp_nonce(void *a, unsigned char **pp);
868edacedfSDaniel Fojt static void *d2i_ocsp_nonce(void *a, const unsigned char **pp, long length);
878edacedfSDaniel Fojt static void ocsp_nonce_free(void *a);
888edacedfSDaniel Fojt static int i2r_ocsp_nonce(const X509V3_EXT_METHOD *method, void *nonce,
898edacedfSDaniel Fojt     BIO *out, int indent);
908edacedfSDaniel Fojt 
918edacedfSDaniel Fojt static int i2r_ocsp_nocheck(const X509V3_EXT_METHOD *method,
928edacedfSDaniel Fojt     void *nocheck, BIO *out, int indent);
938edacedfSDaniel Fojt static void *s2i_ocsp_nocheck(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
948edacedfSDaniel Fojt     const char *str);
958edacedfSDaniel Fojt static int i2r_ocsp_serviceloc(const X509V3_EXT_METHOD *method, void *in,
968edacedfSDaniel Fojt     BIO *bp, int ind);
978edacedfSDaniel Fojt 
988edacedfSDaniel Fojt const X509V3_EXT_METHOD v3_ocsp_crlid = {
998edacedfSDaniel Fojt 	.ext_nid = NID_id_pkix_OCSP_CrlID,
1008edacedfSDaniel Fojt 	.ext_flags = 0,
1018edacedfSDaniel Fojt 	.it = &OCSP_CRLID_it,
1028edacedfSDaniel Fojt 	.ext_new = NULL,
1038edacedfSDaniel Fojt 	.ext_free = NULL,
1048edacedfSDaniel Fojt 	.d2i = NULL,
1058edacedfSDaniel Fojt 	.i2d = NULL,
1068edacedfSDaniel Fojt 	.i2s = NULL,
1078edacedfSDaniel Fojt 	.s2i = NULL,
1088edacedfSDaniel Fojt 	.i2v = NULL,
1098edacedfSDaniel Fojt 	.v2i = NULL,
1108edacedfSDaniel Fojt 	.i2r = i2r_ocsp_crlid,
1118edacedfSDaniel Fojt 	.r2i = NULL,
1128edacedfSDaniel Fojt 	.usr_data = NULL,
1138edacedfSDaniel Fojt };
1148edacedfSDaniel Fojt 
1158edacedfSDaniel Fojt const X509V3_EXT_METHOD v3_ocsp_acutoff = {
1168edacedfSDaniel Fojt 	.ext_nid = NID_id_pkix_OCSP_archiveCutoff,
1178edacedfSDaniel Fojt 	.ext_flags = 0,
1188edacedfSDaniel Fojt 	.it = &ASN1_GENERALIZEDTIME_it,
1198edacedfSDaniel Fojt 	.ext_new = NULL,
1208edacedfSDaniel Fojt 	.ext_free = NULL,
1218edacedfSDaniel Fojt 	.d2i = NULL,
1228edacedfSDaniel Fojt 	.i2d = NULL,
1238edacedfSDaniel Fojt 	.i2s = NULL,
1248edacedfSDaniel Fojt 	.s2i = NULL,
1258edacedfSDaniel Fojt 	.i2v = NULL,
1268edacedfSDaniel Fojt 	.v2i = NULL,
1278edacedfSDaniel Fojt 	.i2r = i2r_ocsp_acutoff,
1288edacedfSDaniel Fojt 	.r2i = NULL,
1298edacedfSDaniel Fojt 	.usr_data = NULL,
1308edacedfSDaniel Fojt };
1318edacedfSDaniel Fojt 
1328edacedfSDaniel Fojt const X509V3_EXT_METHOD v3_crl_invdate = {
1338edacedfSDaniel Fojt 	.ext_nid = NID_invalidity_date,
1348edacedfSDaniel Fojt 	.ext_flags = 0,
1358edacedfSDaniel Fojt 	.it = &ASN1_GENERALIZEDTIME_it,
1368edacedfSDaniel Fojt 	.ext_new = NULL,
1378edacedfSDaniel Fojt 	.ext_free = NULL,
1388edacedfSDaniel Fojt 	.d2i = NULL,
1398edacedfSDaniel Fojt 	.i2d = NULL,
1408edacedfSDaniel Fojt 	.i2s = NULL,
1418edacedfSDaniel Fojt 	.s2i = NULL,
1428edacedfSDaniel Fojt 	.i2v = NULL,
1438edacedfSDaniel Fojt 	.v2i = NULL,
1448edacedfSDaniel Fojt 	.i2r = i2r_ocsp_acutoff,
1458edacedfSDaniel Fojt 	.r2i = NULL,
1468edacedfSDaniel Fojt 	.usr_data = NULL,
1478edacedfSDaniel Fojt };
1488edacedfSDaniel Fojt 
1498edacedfSDaniel Fojt const X509V3_EXT_METHOD v3_crl_hold = {
1508edacedfSDaniel Fojt 	.ext_nid = NID_hold_instruction_code,
1518edacedfSDaniel Fojt 	.ext_flags = 0,
1528edacedfSDaniel Fojt 	.it = &ASN1_OBJECT_it,
1538edacedfSDaniel Fojt 	.ext_new = NULL,
1548edacedfSDaniel Fojt 	.ext_free = NULL,
1558edacedfSDaniel Fojt 	.d2i = NULL,
1568edacedfSDaniel Fojt 	.i2d = NULL,
1578edacedfSDaniel Fojt 	.i2s = NULL,
1588edacedfSDaniel Fojt 	.s2i = NULL,
1598edacedfSDaniel Fojt 	.i2v = NULL,
1608edacedfSDaniel Fojt 	.v2i = NULL,
1618edacedfSDaniel Fojt 	.i2r = i2r_object,
1628edacedfSDaniel Fojt 	.r2i = NULL,
1638edacedfSDaniel Fojt 	.usr_data = NULL,
1648edacedfSDaniel Fojt };
1658edacedfSDaniel Fojt 
1668edacedfSDaniel Fojt const X509V3_EXT_METHOD v3_ocsp_nonce = {
1678edacedfSDaniel Fojt 	.ext_nid = NID_id_pkix_OCSP_Nonce,
1688edacedfSDaniel Fojt 	.ext_flags = 0,
1698edacedfSDaniel Fojt 	.it = NULL,
1708edacedfSDaniel Fojt 	.ext_new = ocsp_nonce_new,
1718edacedfSDaniel Fojt 	.ext_free = ocsp_nonce_free,
1728edacedfSDaniel Fojt 	.d2i = d2i_ocsp_nonce,
1738edacedfSDaniel Fojt 	.i2d = i2d_ocsp_nonce,
1748edacedfSDaniel Fojt 	.i2s = NULL,
1758edacedfSDaniel Fojt 	.s2i = NULL,
1768edacedfSDaniel Fojt 	.i2v = NULL,
1778edacedfSDaniel Fojt 	.v2i = NULL,
1788edacedfSDaniel Fojt 	.i2r = i2r_ocsp_nonce,
1798edacedfSDaniel Fojt 	.r2i = NULL,
1808edacedfSDaniel Fojt 	.usr_data = NULL,
1818edacedfSDaniel Fojt };
1828edacedfSDaniel Fojt 
1838edacedfSDaniel Fojt const X509V3_EXT_METHOD v3_ocsp_nocheck = {
1848edacedfSDaniel Fojt 	.ext_nid = NID_id_pkix_OCSP_noCheck,
1858edacedfSDaniel Fojt 	.ext_flags = 0,
1868edacedfSDaniel Fojt 	.it = &ASN1_NULL_it,
1878edacedfSDaniel Fojt 	.ext_new = NULL,
1888edacedfSDaniel Fojt 	.ext_free = NULL,
1898edacedfSDaniel Fojt 	.d2i = NULL,
1908edacedfSDaniel Fojt 	.i2d = NULL,
1918edacedfSDaniel Fojt 	.i2s = NULL,
1928edacedfSDaniel Fojt 	.s2i = s2i_ocsp_nocheck,
1938edacedfSDaniel Fojt 	.i2v = NULL,
1948edacedfSDaniel Fojt 	.v2i = NULL,
1958edacedfSDaniel Fojt 	.i2r = i2r_ocsp_nocheck,
1968edacedfSDaniel Fojt 	.r2i = NULL,
1978edacedfSDaniel Fojt 	.usr_data = NULL,
1988edacedfSDaniel Fojt };
1998edacedfSDaniel Fojt 
2008edacedfSDaniel Fojt const X509V3_EXT_METHOD v3_ocsp_serviceloc = {
2018edacedfSDaniel Fojt 	.ext_nid = NID_id_pkix_OCSP_serviceLocator,
2028edacedfSDaniel Fojt 	.ext_flags = 0,
2038edacedfSDaniel Fojt 	.it = &OCSP_SERVICELOC_it,
2048edacedfSDaniel Fojt 	.ext_new = NULL,
2058edacedfSDaniel Fojt 	.ext_free = NULL,
2068edacedfSDaniel Fojt 	.d2i = NULL,
2078edacedfSDaniel Fojt 	.i2d = NULL,
2088edacedfSDaniel Fojt 	.i2s = NULL,
2098edacedfSDaniel Fojt 	.s2i = NULL,
2108edacedfSDaniel Fojt 	.i2v = NULL,
2118edacedfSDaniel Fojt 	.v2i = NULL,
2128edacedfSDaniel Fojt 	.i2r = i2r_ocsp_serviceloc,
2138edacedfSDaniel Fojt 	.r2i = NULL,
2148edacedfSDaniel Fojt 	.usr_data = NULL,
2158edacedfSDaniel Fojt };
2168edacedfSDaniel Fojt 
2178edacedfSDaniel Fojt static int
i2r_ocsp_crlid(const X509V3_EXT_METHOD * method,void * in,BIO * bp,int ind)2188edacedfSDaniel Fojt i2r_ocsp_crlid(const X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind)
2198edacedfSDaniel Fojt {
2208edacedfSDaniel Fojt 	OCSP_CRLID *a = in;
2218edacedfSDaniel Fojt 	if (a->crlUrl) {
2228edacedfSDaniel Fojt 		if (BIO_printf(bp, "%*scrlUrl: ", ind, "") <= 0)
2238edacedfSDaniel Fojt 			goto err;
2248edacedfSDaniel Fojt 		if (!ASN1_STRING_print(bp, (ASN1_STRING*)a->crlUrl))
2258edacedfSDaniel Fojt 			goto err;
2268edacedfSDaniel Fojt 		if (BIO_write(bp, "\n", 1) <= 0)
2278edacedfSDaniel Fojt 			goto err;
2288edacedfSDaniel Fojt 	}
2298edacedfSDaniel Fojt 	if (a->crlNum) {
2308edacedfSDaniel Fojt 		if (BIO_printf(bp, "%*scrlNum: ", ind, "") <= 0)
2318edacedfSDaniel Fojt 			goto err;
2328edacedfSDaniel Fojt 		if (i2a_ASN1_INTEGER(bp, a->crlNum) <= 0)
2338edacedfSDaniel Fojt 			goto err;
2348edacedfSDaniel Fojt 		if (BIO_write(bp, "\n", 1) <= 0)
2358edacedfSDaniel Fojt 			goto err;
2368edacedfSDaniel Fojt 	}
2378edacedfSDaniel Fojt 	if (a->crlTime) {
2388edacedfSDaniel Fojt 		if (BIO_printf(bp, "%*scrlTime: ", ind, "") <= 0)
2398edacedfSDaniel Fojt 			goto err;
2408edacedfSDaniel Fojt 		if (!ASN1_GENERALIZEDTIME_print(bp, a->crlTime))
2418edacedfSDaniel Fojt 			goto err;
2428edacedfSDaniel Fojt 		if (BIO_write(bp, "\n", 1) <= 0)
2438edacedfSDaniel Fojt 			goto err;
2448edacedfSDaniel Fojt 	}
2458edacedfSDaniel Fojt 	return 1;
2468edacedfSDaniel Fojt 
2478edacedfSDaniel Fojt err:
2488edacedfSDaniel Fojt 	return 0;
2498edacedfSDaniel Fojt }
2508edacedfSDaniel Fojt 
2518edacedfSDaniel Fojt static int
i2r_ocsp_acutoff(const X509V3_EXT_METHOD * method,void * cutoff,BIO * bp,int ind)2528edacedfSDaniel Fojt i2r_ocsp_acutoff(const X509V3_EXT_METHOD *method, void *cutoff, BIO *bp,
2538edacedfSDaniel Fojt     int ind)
2548edacedfSDaniel Fojt {
2558edacedfSDaniel Fojt 	if (BIO_printf(bp, "%*s", ind, "") <= 0)
2568edacedfSDaniel Fojt 		return 0;
2578edacedfSDaniel Fojt 	if (!ASN1_GENERALIZEDTIME_print(bp, cutoff))
2588edacedfSDaniel Fojt 		return 0;
2598edacedfSDaniel Fojt 	return 1;
2608edacedfSDaniel Fojt }
2618edacedfSDaniel Fojt 
2628edacedfSDaniel Fojt static int
i2r_object(const X509V3_EXT_METHOD * method,void * oid,BIO * bp,int ind)2638edacedfSDaniel Fojt i2r_object(const X509V3_EXT_METHOD *method, void *oid, BIO *bp, int ind)
2648edacedfSDaniel Fojt {
2658edacedfSDaniel Fojt 	if (BIO_printf(bp, "%*s", ind, "") <= 0)
2668edacedfSDaniel Fojt 		return 0;
2678edacedfSDaniel Fojt 	if (i2a_ASN1_OBJECT(bp, oid) <= 0)
2688edacedfSDaniel Fojt 		return 0;
2698edacedfSDaniel Fojt 	return 1;
2708edacedfSDaniel Fojt }
2718edacedfSDaniel Fojt 
2728edacedfSDaniel Fojt /* OCSP nonce. This is needs special treatment because it doesn't have
2738edacedfSDaniel Fojt  * an ASN1 encoding at all: it just contains arbitrary data.
2748edacedfSDaniel Fojt  */
2758edacedfSDaniel Fojt 
2768edacedfSDaniel Fojt static void *
ocsp_nonce_new(void)2778edacedfSDaniel Fojt ocsp_nonce_new(void)
2788edacedfSDaniel Fojt {
2798edacedfSDaniel Fojt 	return ASN1_OCTET_STRING_new();
2808edacedfSDaniel Fojt }
2818edacedfSDaniel Fojt 
2828edacedfSDaniel Fojt static int
i2d_ocsp_nonce(void * a,unsigned char ** pp)2838edacedfSDaniel Fojt i2d_ocsp_nonce(void *a, unsigned char **pp)
2848edacedfSDaniel Fojt {
2858edacedfSDaniel Fojt 	ASN1_OCTET_STRING *os = a;
2868edacedfSDaniel Fojt 
2878edacedfSDaniel Fojt 	if (pp) {
2888edacedfSDaniel Fojt 		memcpy(*pp, os->data, os->length);
2898edacedfSDaniel Fojt 		*pp += os->length;
2908edacedfSDaniel Fojt 	}
2918edacedfSDaniel Fojt 	return os->length;
2928edacedfSDaniel Fojt }
2938edacedfSDaniel Fojt 
2948edacedfSDaniel Fojt static void *
d2i_ocsp_nonce(void * a,const unsigned char ** pp,long length)2958edacedfSDaniel Fojt d2i_ocsp_nonce(void *a, const unsigned char **pp, long length)
2968edacedfSDaniel Fojt {
2978edacedfSDaniel Fojt 	ASN1_OCTET_STRING *os, **pos;
2988edacedfSDaniel Fojt 
2998edacedfSDaniel Fojt 	pos = a;
3008edacedfSDaniel Fojt 	if (pos == NULL || *pos == NULL) {
3018edacedfSDaniel Fojt 		os = ASN1_OCTET_STRING_new();
3028edacedfSDaniel Fojt 		if (os == NULL)
3038edacedfSDaniel Fojt 			goto err;
3048edacedfSDaniel Fojt 	} else
3058edacedfSDaniel Fojt 		os = *pos;
3068edacedfSDaniel Fojt 	if (ASN1_OCTET_STRING_set(os, *pp, length) == 0)
3078edacedfSDaniel Fojt 		goto err;
3088edacedfSDaniel Fojt 
3098edacedfSDaniel Fojt 	*pp += length;
3108edacedfSDaniel Fojt 
3118edacedfSDaniel Fojt 	if (pos != NULL)
3128edacedfSDaniel Fojt 		*pos = os;
3138edacedfSDaniel Fojt 	return os;
3148edacedfSDaniel Fojt 
3158edacedfSDaniel Fojt err:
3168edacedfSDaniel Fojt 	if (pos == NULL || *pos != os)
3178edacedfSDaniel Fojt 		ASN1_OCTET_STRING_free(os);
3188edacedfSDaniel Fojt 	OCSPerror(ERR_R_MALLOC_FAILURE);
3198edacedfSDaniel Fojt 	return NULL;
3208edacedfSDaniel Fojt }
3218edacedfSDaniel Fojt 
3228edacedfSDaniel Fojt static void
ocsp_nonce_free(void * a)3238edacedfSDaniel Fojt ocsp_nonce_free(void *a)
3248edacedfSDaniel Fojt {
3258edacedfSDaniel Fojt 	ASN1_OCTET_STRING_free(a);
3268edacedfSDaniel Fojt }
3278edacedfSDaniel Fojt 
3288edacedfSDaniel Fojt static int
i2r_ocsp_nonce(const X509V3_EXT_METHOD * method,void * nonce,BIO * out,int indent)3298edacedfSDaniel Fojt i2r_ocsp_nonce(const X509V3_EXT_METHOD *method, void *nonce, BIO *out,
3308edacedfSDaniel Fojt     int indent)
3318edacedfSDaniel Fojt {
3328edacedfSDaniel Fojt 	if (BIO_printf(out, "%*s", indent, "") <= 0)
3338edacedfSDaniel Fojt 		return 0;
3348edacedfSDaniel Fojt 	if (i2a_ASN1_STRING(out, nonce, V_ASN1_OCTET_STRING) <= 0)
3358edacedfSDaniel Fojt 		return 0;
3368edacedfSDaniel Fojt 	return 1;
3378edacedfSDaniel Fojt }
3388edacedfSDaniel Fojt 
3398edacedfSDaniel Fojt /* Nocheck is just a single NULL. Don't print anything and always set it */
3408edacedfSDaniel Fojt 
3418edacedfSDaniel Fojt static int
i2r_ocsp_nocheck(const X509V3_EXT_METHOD * method,void * nocheck,BIO * out,int indent)3428edacedfSDaniel Fojt i2r_ocsp_nocheck(const X509V3_EXT_METHOD *method, void *nocheck, BIO *out,
3438edacedfSDaniel Fojt     int indent)
3448edacedfSDaniel Fojt {
3458edacedfSDaniel Fojt 	return 1;
3468edacedfSDaniel Fojt }
3478edacedfSDaniel Fojt 
3488edacedfSDaniel Fojt static void *
s2i_ocsp_nocheck(const X509V3_EXT_METHOD * method,X509V3_CTX * ctx,const char * str)3498edacedfSDaniel Fojt s2i_ocsp_nocheck(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
3508edacedfSDaniel Fojt     const char *str)
3518edacedfSDaniel Fojt {
3528edacedfSDaniel Fojt 	return ASN1_NULL_new();
3538edacedfSDaniel Fojt }
3548edacedfSDaniel Fojt 
3558edacedfSDaniel Fojt static int
i2r_ocsp_serviceloc(const X509V3_EXT_METHOD * method,void * in,BIO * bp,int ind)3568edacedfSDaniel Fojt i2r_ocsp_serviceloc(const X509V3_EXT_METHOD *method, void *in, BIO *bp, int ind)
3578edacedfSDaniel Fojt {
3588edacedfSDaniel Fojt 	int i;
3598edacedfSDaniel Fojt 	OCSP_SERVICELOC *a = in;
3608edacedfSDaniel Fojt 	ACCESS_DESCRIPTION *ad;
3618edacedfSDaniel Fojt 
3628edacedfSDaniel Fojt 	if (BIO_printf(bp, "%*sIssuer: ", ind, "") <= 0)
3638edacedfSDaniel Fojt 		goto err;
3648edacedfSDaniel Fojt 	if (X509_NAME_print_ex(bp, a->issuer, 0, XN_FLAG_ONELINE) <= 0)
3658edacedfSDaniel Fojt 		goto err;
3668edacedfSDaniel Fojt 	for (i = 0; i < sk_ACCESS_DESCRIPTION_num(a->locator); i++) {
3678edacedfSDaniel Fojt 		ad = sk_ACCESS_DESCRIPTION_value(a->locator, i);
3688edacedfSDaniel Fojt 		if (BIO_printf(bp, "\n%*s", (2 * ind), "") <= 0)
3698edacedfSDaniel Fojt 			goto err;
3708edacedfSDaniel Fojt 		if (i2a_ASN1_OBJECT(bp, ad->method) <= 0)
3718edacedfSDaniel Fojt 			goto err;
3728edacedfSDaniel Fojt 		if (BIO_puts(bp, " - ") <= 0)
3738edacedfSDaniel Fojt 			goto err;
3748edacedfSDaniel Fojt 		if (GENERAL_NAME_print(bp, ad->location) <= 0)
3758edacedfSDaniel Fojt 			goto err;
3768edacedfSDaniel Fojt 	}
3778edacedfSDaniel Fojt 	return 1;
3788edacedfSDaniel Fojt 
3798edacedfSDaniel Fojt err:
3808edacedfSDaniel Fojt 	return 0;
3818edacedfSDaniel Fojt }
3828edacedfSDaniel Fojt #endif
383