Commit 1f47ec53 authored by Dr. Stephen Henson's avatar Dr. Stephen Henson
Browse files

Redo OCSP response printing. Remove duplicate or
obsolete code. Delete some redundant files.
parent 959f67d6
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -22,12 +22,11 @@ TEST=
APPS=

LIB=$(TOP)/libcrypto.a
LIBSRC= ocsp_asn.c ocsp_ext.c ocsp_res.c ocsp_sig.c ocsp_cid.c \
LIBSRC= ocsp_asn.c ocsp_ext.c \
	ocsp_lib.c ocsp_prn.c ocsp_err.c
#ocsp_v3.c
LIBOBJ= ocsp_asn.o ocsp_ext.o ocsp_res.o ocsp_sig.o ocsp_cid.o \

LIBOBJ= ocsp_asn.o ocsp_ext.o \
	ocsp_lib.o ocsp_prn.o ocsp_err.o
#ocsp_v3.o

SRC= $(LIBSRC)

+3 −35
Original line number Diff line number Diff line
@@ -445,104 +445,72 @@ X509_EXTENSION *OCSP_archive_cutoff_new(char* tim);
X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME* issuer, char **urls);

DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP)
int i2a_OCSP_SINGLERESP(BIO *bp, OCSP_SINGLERESP* a);

OCSP_CERTSTATUS *OCSP_CERTSTATUS_new(void);
void OCSP_CERTSTATUS_free(OCSP_CERTSTATUS *a);
int i2d_OCSP_CERTSTATUS(OCSP_CERTSTATUS *a, unsigned char **pp);
OCSP_CERTSTATUS *d2i_OCSP_CERTSTATUS(OCSP_CERTSTATUS **a, unsigned char **pp, long length);
int i2a_OCSP_CERTSTATUS(BIO *bp, OCSP_CERTSTATUS* a);

OCSP_REVOKEDINFO *OCSP_REVOKEDINFO_new(void);
void OCSP_REVOKEDINFO_free(OCSP_REVOKEDINFO *a);
int i2d_OCSP_REVOKEDINFO(OCSP_REVOKEDINFO *a, unsigned char **pp);
OCSP_REVOKEDINFO *d2i_OCSP_REVOKEDINFO(OCSP_REVOKEDINFO **a, unsigned char **pp, long length);
int i2a_OCSP_REVOKEDINFO(BIO *bp, OCSP_REVOKEDINFO* a);

OCSP_BASICRESP *OCSP_BASICRESP_new(void);
void OCSP_BASICRESP_free(OCSP_BASICRESP *a);
int i2d_OCSP_BASICRESP(OCSP_BASICRESP *a, unsigned char **pp);
OCSP_BASICRESP *d2i_OCSP_BASICRESP(OCSP_BASICRESP **a, unsigned char **pp, long length);
int i2a_OCSP_BASICRESP(BIO *bp, OCSP_BASICRESP* a);

OCSP_RESPDATA *OCSP_RESPDATA_new(void);
void OCSP_RESPDATA_free(OCSP_RESPDATA *a);
int i2d_OCSP_RESPDATA(OCSP_RESPDATA *a, unsigned char **pp);
OCSP_RESPDATA *d2i_OCSP_RESPDATA(OCSP_RESPDATA **a, unsigned char **pp, long length);
int i2a_OCSP_RESPDATA(BIO *bp, OCSP_RESPDATA* a);

OCSP_RESPID *OCSP_RESPID_new(void);
void OCSP_RESPID_free(OCSP_RESPID *a);
int i2d_OCSP_RESPID(OCSP_RESPID *a, unsigned char **pp);
OCSP_RESPID *d2i_OCSP_RESPID(OCSP_RESPID **a, unsigned char **pp, long length);
int i2a_OCSP_RESPID(BIO *bp, OCSP_RESPID* a);

OCSP_RESPONSE *OCSP_RESPONSE_new(void);
void OCSP_RESPONSE_free(OCSP_RESPONSE *a);
int i2d_OCSP_RESPONSE(OCSP_RESPONSE *a, unsigned char **pp);
OCSP_RESPONSE *d2i_OCSP_RESPONSE(OCSP_RESPONSE **a, unsigned char **pp, long length);
int i2a_OCSP_RESPONSE(BIO *bp, OCSP_RESPONSE* a);
int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* a);
int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* a, unsigned long flags);

OCSP_RESPBYTES *OCSP_RESPBYTES_new(void);
void OCSP_RESPBYTES_free(OCSP_RESPBYTES *a);
int i2d_OCSP_RESPBYTES(OCSP_RESPBYTES *a, unsigned char **pp);
OCSP_RESPBYTES *d2i_OCSP_RESPBYTES(OCSP_RESPBYTES **a, unsigned char **pp, long length);
int i2a_OCSP_RESPBYTES(BIO *bp, OCSP_RESPBYTES* a);

OCSP_ONEREQ *OCSP_ONEREQ_new(void);
void OCSP_ONEREQ_free(OCSP_ONEREQ *a);
int i2d_OCSP_ONEREQ(OCSP_ONEREQ *a, unsigned char **pp);
OCSP_ONEREQ *d2i_OCSP_ONEREQ(OCSP_ONEREQ **a, unsigned char **pp, long length);
int i2a_OCSP_ONEREQ(BIO *bp, OCSP_ONEREQ* a);

OCSP_CERTID *OCSP_CERTID_new(void);
void OCSP_CERTID_free(OCSP_CERTID *a);
int i2d_OCSP_CERTID(OCSP_CERTID *a, unsigned char **pp);
OCSP_CERTID *d2i_OCSP_CERTID(OCSP_CERTID **a, unsigned char **pp, long length);
int i2a_OCSP_CERTID(BIO *bp, OCSP_CERTID* a);

OCSP_REQUEST *OCSP_REQUEST_new(void);
void OCSP_REQUEST_free(OCSP_REQUEST *a);
int i2d_OCSP_REQUEST(OCSP_REQUEST *a, unsigned char **pp);
OCSP_REQUEST *d2i_OCSP_REQUEST(OCSP_REQUEST **a, unsigned char **pp, long length);
int i2a_OCSP_REQUEST(BIO *bp, OCSP_REQUEST* a);

int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* a, unsigned long flags);

OCSP_SIGNATURE *OCSP_SIGNATURE_new(void);
void OCSP_SIGNATURE_free(OCSP_SIGNATURE *a);
int i2d_OCSP_SIGNATURE(OCSP_SIGNATURE *a, unsigned char **pp);
OCSP_SIGNATURE *d2i_OCSP_SIGNATURE(OCSP_SIGNATURE **a, unsigned char **pp, long length);
int i2a_OCSP_SIGNATURE(BIO *bp, OCSP_SIGNATURE* a);

DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO)
int i2a_OCSP_REQINFO(BIO *bp, OCSP_REQINFO* a);

DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO)
DECLARE_ASN1_FUNCTIONS(OCSP_CRLID)
int i2a_OCSP_CRLID(BIO *bp, OCSP_CRLID* a);
int OCSP_CRLID_print(BIO *bp, OCSP_CRLID *a, int ind);

DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC)
int i2a_OCSP_SERVICELOC(BIO *bp, OCSP_SERVICELOC* a);
int OCSP_SERVICELOC_print(BIO *bp, OCSP_SERVICELOC* a, int ind);

int OCSP_extensions_print(BIO *bp, STACK_OF(X509_EXTENSION) *sk, char *title);
int OCSP_extension_print(BIO *bp, X509_EXTENSION *x, int ind);

void ERR_load_OCSP_strings(void);

#if 0 /* Not yet implemented */
X509_EXTENSION *OCSP_nochain_new(void);
#endif

char* ocspResponseStatus2string(long s);
char* ocspCertStatus2string(long s);
char * cRLReason2string(long s);

#if 0 /* Not yet implemented */
void OCSP_add_standard_extension(void);
#endif

/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.

crypto/ocsp/ocsp_cid.c

deleted100644 → 0
+0 −82
Original line number Diff line number Diff line
/* ocsp_cid.c */
/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
 * project. */

/* History:
   This file was originally part of ocsp.c and was transfered to Richard
   Levitte from CertCo by Kathy Weinhold in mid-spring 2000 to be included
   in OpenSSL or released as a patch kit. */

/* ====================================================================
 * Copyright (c) 1998-2000 The OpenSSL Project.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 *
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    openssl-core@openssl.org.
 *
 * 5. Products derived from this software may not be called "OpenSSL"
 *    nor may "OpenSSL" appear in their names without prior written
 *    permission of the OpenSSL Project.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the OpenSSL Project
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 *
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 * ====================================================================
 *
 * This product includes cryptographic software written by Eric Young
 * (eay@cryptsoft.com).  This product includes software written by Tim
 * Hudson (tjh@cryptsoft.com).
 *
 */

#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/ocsp.h>
#include <openssl/x509.h>

int i2a_OCSP_CERTID(BIO *bp,
		    OCSP_CERTID* a)
        {
#ifdef UNDEF
	/* XXX this guy isn't implemented. */
	i2a_X509_ALGOR(bp, a->hashAlgorithm);
#else   /* instead, just show OID, not param */
	i2a_ASN1_OBJECT(bp, a->hashAlgorithm->algorithm);
#endif
	i2a_ASN1_STRING(bp, a->issuerNameHash, V_ASN1_OCTET_STRING);
	i2a_ASN1_STRING(bp, a->issuerKeyHash, V_ASN1_OCTET_STRING);
	i2a_ASN1_INTEGER(bp, a->serialNumber);
	return 4;
	}
+0 −96
Original line number Diff line number Diff line
@@ -251,99 +251,3 @@ err:
	return NULL;
	}
int OCSP_extensions_print(BIO *bp,
			  STACK_OF(X509_EXTENSION) *sk,
			  char *title)
        {
	int i;
	if (!sk) return 1;
	if (BIO_printf(bp, "%s:\n", title) <= 0) return 0; 
	for (i=0; i<sk_X509_EXTENSION_num(sk); i++)
	        OCSP_extension_print(bp, sk_X509_EXTENSION_value(sk,i), 4);
	return sk_X509_EXTENSION_num(sk);
	}

int OCSP_extension_print(BIO *bp,
			 X509_EXTENSION *x,
			 int ind)
        {
	int i, j;
	STACK_OF(ASN1_OBJECT) *sk = NULL;
	unsigned char *p;
	OCSP_CRLID *crlid = NULL;
	OCSP_SERVICELOC *sloc = NULL;
	ASN1_GENERALIZEDTIME *gt = NULL;

	if (!x) return 1;
	switch (OBJ_obj2nid(x->object))
	        {
		case NID_id_pkix_OCSP_Nonce:
		        if (BIO_printf(bp, "%*snonce: ", ind, "") <= 0) 
			        goto err;
			if (M_ASN1_OCTET_STRING_print(bp, x->value) <= 0)
			        goto err;
			if (BIO_write(bp, "\n", 1) <= 0) goto err;
		        break;
		case NID_id_pkix_OCSP_CrlID:
		        if (BIO_printf(bp, "%*scrlId:\n", ind, "") <= 0) 
			        goto err;
		        p = x->value->data;
		        if (!(d2i_OCSP_CRLID(&crlid, &p, x->value->length)))
			        goto err;
			if (!OCSP_CRLID_print(bp, crlid, (2*ind))) goto err;
			OCSP_CRLID_free(crlid);
		        break;
		case NID_id_pkix_OCSP_acceptableResponses:
		        if (BIO_printf(bp, 
				      "%*sacceptable responses: ", 
				      ind, "") <= 0)
			        goto err;
		        p = x->value->data;
		        if (!(d2i_ASN1_SET_OF_ASN1_OBJECT(&sk, &p, x->value->length, 
					   d2i_ASN1_OBJECT, 
					   ASN1_OBJECT_free,
					   V_ASN1_SEQUENCE, 
					   V_ASN1_UNIVERSAL)))
			        goto err;
			for (i = 0; i < sk_ASN1_OBJECT_num(sk); i++)
			        {
		                j=OBJ_obj2nid(sk_ASN1_OBJECT_value(sk,i));
		                if (BIO_printf(bp," %s ",
					       (j == NID_undef)?"UNKNOWN":
					                   OBJ_nid2ln(j)) <= 0)
				          goto err;
				}
			if (BIO_write(bp, "\n", 1) <= 0) goto err;
			sk_ASN1_OBJECT_pop_free(sk, ASN1_OBJECT_free);
		        break;
		case NID_id_pkix_OCSP_archiveCutoff:
		        if (BIO_printf(bp, "%*sarchive cutoff: ", ind, "")<=0)
			        goto err;
		        p = x->value->data;
			if (!d2i_ASN1_GENERALIZEDTIME(&gt, &p, 
						      x->value->length))
			        goto err;
			if (!ASN1_GENERALIZEDTIME_print(bp, gt)) goto err;
			if (BIO_write(bp, "\n", 1) <= 0) goto err;
			ASN1_GENERALIZEDTIME_free(gt);
		        break;
		case NID_id_pkix_OCSP_serviceLocator:
		  if (BIO_printf(bp, "%*sservice locator:\n", ind, "") <= 0)
			        goto err;
		        p = x->value->data;
			if (!d2i_OCSP_SERVICELOC(&sloc, &p, 
						 x->value->length))
			        goto err;
			if (!OCSP_SERVICELOC_print(bp,sloc,(2*ind))) goto err;
			OCSP_SERVICELOC_free(sloc);
		        break;
	        case NID_undef:
	        default:
		        if (BIO_printf(bp,"%*sunrecognized oid: ",ind,"") <= 0)
			        goto err;
		        break;
		}
	return 1;
err:
	return 0;
	}
+0 −273
Original line number Diff line number Diff line
@@ -367,279 +367,6 @@ err:
	return NULL;
	}

char* ocspResponseStatus2string(long s)
        {
	static struct { long t; char *m; } ts[6]= { 
	        { OCSP_RESPONSE_STATUS_SUCCESSFULL, "successful" },
	        { OCSP_RESPONSE_STATUS_MALFORMEDREQUEST, "malformedrequest" },
	        { OCSP_RESPONSE_STATUS_INTERNALERROR, "internalerror" },
	        { OCSP_RESPONSE_STATUS_TRYLATER, "trylater" },
	        { OCSP_RESPONSE_STATUS_SIGREQUIRED, "sigrequired" },
	        { OCSP_RESPONSE_STATUS_UNAUTHORIZED, "unauthorized" } }, *p;
	for (p=ts; p < &ts[sizeof ts/sizeof ts[0]]; p++)
	        if (p->t == s)
		         return p->m;
	return "(UNKNOWN)";
	} 

char* ocspCertStatus2string(long s)
        {
	static struct { long t; char *m; } ts[3]= { 
	        { V_OCSP_CERTSTATUS_GOOD, "good" },
	        { V_OCSP_CERTSTATUS_REVOKED, "revoked" },
	        { V_OCSP_CERTSTATUS_UNKNOWN, "unknown" } }, *p;
	for (p=ts; p < &ts[sizeof ts/sizeof ts[0]]; p++)
	        if (p->t == s)
		         return p->m;
	return "(UNKNOWN)";
	} 

char * cRLReason2string(long s)
        {
	static struct { long t; char *m; } ts[8]= { 
	  { OCSP_REVOKED_STATUS_UNSPECIFIED, "unspecified" },
          { OCSP_REVOKED_STATUS_KEYCOMPROMISE, "keyCompromise" },
          { OCSP_REVOKED_STATUS_CACOMPROMISE, "cACompromise" },
          { OCSP_REVOKED_STATUS_AFFILIATIONCHANGED, "affiliationChanged" },
          { OCSP_REVOKED_STATUS_SUPERSEDED, "superseded" },
          { OCSP_REVOKED_STATUS_CESSATIONOFOPERATION, "cessationOfOperation" },
          { OCSP_REVOKED_STATUS_CERTIFICATEHOLD, "certificateHold" },
          { OCSP_REVOKED_STATUS_REMOVEFROMCRL, "removeFromCRL" } }, *p;
	for (p=ts; p < &ts[sizeof ts/sizeof ts[0]]; p++)
	        if (p->t == s)
		         return p->m;
	return "(UNKNOWN)";
	} 

static int i2a_GENERAL_NAME(bp,n)
BIO *bp; 
GENERAL_NAME *n;
	{
	int j;
        char *p;

	if (n == NULL) return(0);

	switch (n->type)
		{

	case GEN_DIRNAME:
	        X509_NAME_print(bp,n->d.dirn,16);
		break;

	case GEN_EMAIL:
	case GEN_DNS:
	case GEN_URI:
	case GEN_IPADD:
		p=(char *)n->d.ip->data;
		for (j=n->d.ip->length;j>0;j--)
			{
			if ((*p >= ' ') && (*p <= '~'))
			        BIO_printf(bp,"%c",*p);
			else if (*p & 0x80)
			        BIO_printf(bp,"\\0x%02X",*p);
			else if ((unsigned char)*p == 0xf7)
			        BIO_printf(bp,"^?");
			else	BIO_printf(bp,"^%c",*p+'@');
			p++;
			}
		break;

	case GEN_RID:
	        i2a_ASN1_OBJECT(bp, n->d.rid);
		break;

	/* XXX these are legit, need to support at some time... */
	case GEN_OTHERNAME:
	case GEN_X400:
	case GEN_EDIPARTY:
	default:
	        return 0;
		}

	return 1;
	}

int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o)
        {
	int i, j, n;
	long l;
	char *s;
	unsigned char *p;
	OCSP_CERTID *cid = NULL;
	OCSP_BASICRESP *br = NULL;
	OCSP_RESPDATA  *rd = NULL;
	OCSP_CERTSTATUS *cst = NULL;
	OCSP_REVOKEDINFO *rev = NULL;
	OCSP_SINGLERESP *single = NULL;
	OCSP_RESPBYTES *rb = o->responseBytes;

	l=ASN1_ENUMERATED_get(o->responseStatus);
	if (BIO_printf(bp,"OCSP Response Status: %s (0x%x)\n", 
		       ocspResponseStatus2string(l), l) <= 0) goto err;
	if (rb == NULL) return 1;
	i=OBJ_obj2nid(rb->responseType);
        if (BIO_printf(bp,"OCSP Response Bytes Response Type: %s",
		       (i == NID_undef)?"UNKNOWN":OBJ_nid2sn(i)) <= 0)
	        goto err;
	if (i != NID_id_pkix_OCSP_basic) 
	        {
		BIO_printf(bp," (unknown response type)\n");
		return 1;
		}
	p = ASN1_STRING_data(rb->response);
	i = ASN1_STRING_length(rb->response);
	if (!(d2i_OCSP_BASICRESP(&br, &p, i))) goto err;
	rd = br->tbsResponseData;
	l=ASN1_INTEGER_get(rd->version);
	if (BIO_printf(bp,"\nBasic Response Data Version: %lu (0x%lx)\n",
		       l+1,l) <= 0) goto err;
	if (BIO_printf(bp,"Basic Response Data Responder Id: ") <= 0) goto err;
	i2a_OCSP_RESPID(bp, rd->responderId);
	if (BIO_printf(bp,"\nBasic Response Data Produced At: ")<=0) goto err;
	if (!ASN1_GENERALIZEDTIME_print(bp, rd->producedAt)) goto err;
	if (BIO_printf(bp,"\nBasic Response Data Responses:\n") <= 0) goto err;
	for (i = 0; i < sk_OCSP_SINGLERESP_num(rd->responses); i++)
	        {
		if (! sk_OCSP_SINGLERESP_value(rd->responses, i)) continue;
		single = sk_OCSP_SINGLERESP_value(rd->responses, i);
		cid = single->certId;
		j=OBJ_obj2nid(cid->hashAlgorithm->algorithm);
		if (BIO_printf(bp,"    Cert Id:") <= 0) goto err;
		if (BIO_printf(bp,"\n%8sHash Algorithm: %s","",
			       (j == NID_undef)?"UNKNOWN":OBJ_nid2ln(j)) <= 0)
		        goto err;
		if (BIO_write(bp,"\n        Issuer Name Hash: ",27) <= 0)
		        goto err;
		i2a_ASN1_STRING(bp, cid->issuerNameHash, V_ASN1_OCTET_STRING);
		if (BIO_write(bp,"\n        Issuer Key Hash: ",26) <= 0) 
		        goto err;
		i2a_ASN1_STRING(bp, cid->issuerKeyHash, V_ASN1_OCTET_STRING);
		if (BIO_write(bp,"\n        Serial Number: ",24) <= 0) 
		        goto err;
		if (!i2a_ASN1_INTEGER(bp, cid->serialNumber)) 
		        goto err;
		cst = single->certStatus;
		if (BIO_printf(bp,"\n    Cert Status: %s (0x%x)",
			       ocspCertStatus2string(cst->type), cst->type) <= 0)
		        goto err;
		if (cst->type == V_OCSP_CERTSTATUS_REVOKED)
		        {
		        rev = cst->value.revoked;
			if (BIO_printf(bp, "\n    Revocation Time: ") <= 0) 
			        goto err;
			if (!ASN1_GENERALIZEDTIME_print(bp, 
							rev->revocationTime)) 
				goto err;
			if (rev->revocationReason) 
			        {
				l=ASN1_ENUMERATED_get(rev->revocationReason);
				if (BIO_printf(bp, 
					 "\n    Revocation Reason: %s (0x%x)",
					       cRLReason2string(l), l) <= 0)
				        goto err;
				}
			}
		if (BIO_printf(bp,"\n    This Update: ") <= 0) goto err;
		if (!ASN1_GENERALIZEDTIME_print(bp, single->thisUpdate)) 
			goto err;
		if (single->nextUpdate)
		        {
			if (BIO_printf(bp,"\n    Next Update: ") <= 0)goto err;
			if (!ASN1_GENERALIZEDTIME_print(bp,single->nextUpdate))
				goto err;
			}
		if (!BIO_write(bp,"\n",1)) goto err;
		if (!OCSP_extensions_print(bp, single->singleExtensions,
					   "Basic Response Single Extensions"))
		        goto err;
		}
	if (!OCSP_extensions_print(bp, rd->responseExtensions,
				   "Basic Response Extensions")) goto err;
	i=OBJ_obj2nid(br->signatureAlgorithm->algorithm);
	if (BIO_printf(bp,"Basic Response Signature Algorithm: %s",
		       (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)) <= 0)
	        goto err;
	n=br->signature->length;
	s=(char *)br->signature->data;
	for (i=0; i<n; i++)
		{
		if ((i%18) == 0)
		if (BIO_write(bp,"\n        ",9) <= 0) goto err;
		if (BIO_printf(bp,"%02x%s",(unsigned char)s[i],
			((i+1) == n)?"":":") <= 0) goto err;
		}
	if (BIO_write(bp,"\n",1) != 1) goto err;
	if (br->certs)
	        {
		for (i=0; i<sk_X509_num(br->certs); i++)
			if (sk_X509_value(br->certs,i) != NULL) {
				X509_print(bp, sk_X509_value(br->certs,i));
				PEM_write_bio_X509(bp,sk_X509_value(br->certs,i));
			}
		}
	return 1;
err:
	return 0;
	}

int OCSP_CRLID_print(BIO *bp, OCSP_CRLID *a, int ind)
        {
	if (a->crlUrl)
	        {
		if (!BIO_printf(bp, "%*scrlUrl: ", ind, "")) goto err;
		if (!ASN1_STRING_print(bp, (ASN1_STRING*)a->crlUrl)) goto err;
		if (!BIO_write(bp, "\n", 1)) goto err;
		}
	if (a->crlNum)
	        {
		if (!BIO_printf(bp, "%*scrlNum: ", ind, "")) goto err;
		if (!i2a_ASN1_INTEGER(bp, a->crlNum)) goto err;
		if (!BIO_write(bp, "\n", 1)) goto err;
		}
	if (a->crlTime)
	        {
		if (!BIO_printf(bp, "%*scrlTime: ", ind, "")) goto err;
		if (!ASN1_GENERALIZEDTIME_print(bp, a->crlTime)) goto err;
		if (!BIO_write(bp, "\n", 1)) goto err;
		}
	return 1;
err:
	return 0;
	}

int OCSP_SERVICELOC_print(BIO *bp, OCSP_SERVICELOC* a, int ind)
        {
	int i, j;
	ACCESS_DESCRIPTION *ad;

        if (BIO_printf(bp, "%*sissuer: ", ind, "") <= 0) goto err;
        if (X509_NAME_print(bp, a->issuer, 16) <= 0) goto err;
        if (BIO_printf(bp, "\n", 1) <= 0) goto err;

		/* Service locator is optional */
		if (a->locator != NULL) {
			if (BIO_printf(bp, "%*slocator:\n", ind, "") <= 0) goto err;
			for (i = 0; i < sk_ACCESS_DESCRIPTION_num(a->locator); i++)
	        {
				ad = sk_ACCESS_DESCRIPTION_value(a->locator,i);
				if (BIO_printf(bp, "%*smethod: ", (2*ind), "") <= 0) 
					goto err;
				j=OBJ_obj2nid(ad->method);
				if (BIO_printf(bp,"%s", (j == NID_undef)?"UNKNOWN":
							   OBJ_nid2ln(j)) <= 0)
					goto err;
				if (BIO_printf(bp, "\n%*sname: ", (2*ind), "") <= 0) 
					goto err;
				if (i2a_GENERAL_NAME(bp, ad->location) <= 0) goto err;
				if (BIO_write(bp, "\n", 1) <= 0) goto err;
			}
		}
	return 1;
err:
	return 0;
	}

/* XXX assumes certs in signature are sorted root to leaf XXX */
int OCSP_request_verify(OCSP_REQUEST *req, EVP_PKEY *pkey)
        {
Loading