Commit 2c15d426 authored by Dr. Stephen Henson's avatar Dr. Stephen Henson
Browse files

New function X509V3_extensions_print() this removes extension duplication

from the print routines.

Reorganisation of OCSP code: initial print routines in ocsp_prn.c. Doesn't
work fully because OCSP extensions aren't reimplemented yet.

Implement some ASN1 functions needed to compile OCSP code.
parent bdcfe1d1
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -3,6 +3,11 @@

 Changes between 0.9.6 and 0.9.7  [xx XXX 2000]

  *) Move common extension printing code to new function
     X509V3_print_extensions(). Reorganise OCSP print routines and
     implement some needed OCSP ASN1 functions.
     [Steve Henson]

  *) New function X509_signature_print() to remove duplication in some
     print routines.
     [Steve Henson]
+5 −25
Original line number Diff line number Diff line
@@ -64,7 +64,6 @@
#include <openssl/x509.h>
#include <openssl/x509v3.h>

static void ext_print(BIO *out, X509_EXTENSION *ex);
#ifndef NO_FP_API
int X509_CRL_print_fp(FILE *fp, X509_CRL *x)
        {
@@ -89,7 +88,7 @@ int X509_CRL_print(BIO *out, X509_CRL *x)
	STACK_OF(X509_REVOKED) *rev;
	X509_REVOKED *r;
	long l;
	int i, j, n;
	int i, n;

	BIO_printf(out, "Certificate Revocation List (CRL):\n");
	l = X509_CRL_get_version(x);
@@ -108,11 +107,8 @@ int X509_CRL_print(BIO *out, X509_CRL *x)
	BIO_printf(out,"\n");

	n=X509_CRL_get_ext_count(x);
	if (n > 0) {
		BIO_printf(out,"%8sCRL extensions:\n","");
		for (i=0; i<n; i++) ext_print(out, X509_CRL_get_ext(x, i));
	}

	X509V3_extensions_print(out, "CRL extensions",
						x->crl->extensions, 0, 8);

	rev = X509_CRL_get_REVOKED(x);

@@ -127,27 +123,11 @@ int X509_CRL_print(BIO *out, X509_CRL *x)
		BIO_printf(out,"\n        Revocation Date: ","");
		ASN1_TIME_print(out,r->revocationDate);
		BIO_printf(out,"\n");
		for(j = 0; j < X509_REVOKED_get_ext_count(r); j++)
				ext_print(out, X509_REVOKED_get_ext(r, j));
		X509V3_extensions_print(out, "CRL entry extensions",
						r->extensions, 0, 8);
	}
	X509_signature_print(out, x->sig_alg, x->signature);

	return 1;

}

static void ext_print(BIO *out, X509_EXTENSION *ex)
{
	ASN1_OBJECT *obj;
	int j;
	BIO_printf(out,"%12s","");
	obj=X509_EXTENSION_get_object(ex);
	i2a_ASN1_OBJECT(out,obj);
	j=X509_EXTENSION_get_critical(ex);
	BIO_printf(out, ": %s\n", j ? "critical":"","");
	if(!X509V3_EXT_print(out, ex, 0, 16)) {
		BIO_printf(out, "%16s", "");
		M_ASN1_OCTET_STRING_print(out,ex->value);
	}
	BIO_write(out,"\n",1);
}
+4 −27
Original line number Diff line number Diff line
@@ -101,14 +101,13 @@ int X509_print(BIO *bp, X509 *x)
int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
	{
	long l;
	int ret=0,i,j,n;
	int ret=0,i;
	char *m=NULL,mlch = ' ';
	int nmindent = 0;
	X509_CINF *ci;
	ASN1_INTEGER *bs;
	EVP_PKEY *pkey=NULL;
	const char *neg;
	X509_EXTENSION *ex;
	ASN1_STRING *str=NULL;

	if((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) {
@@ -228,31 +227,9 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
		EVP_PKEY_free(pkey);
		}

	if (cflag & X509_FLAG_NO_EXTENSIONS)
		n = 0;
	else
		n=X509_get_ext_count(x);
	if (n > 0)
		{
		BIO_printf(bp,"%8sX509v3 extensions:\n","");
		for (i=0; i<n; i++)
			{
			ASN1_OBJECT *obj;
			ex=X509_get_ext(x,i);
			if (BIO_printf(bp,"%12s","") <= 0) goto err;
			obj=X509_EXTENSION_get_object(ex);
			i2a_ASN1_OBJECT(bp,obj);
			j=X509_EXTENSION_get_critical(ex);
			if (BIO_printf(bp,": %s\n",j?"critical":"","") <= 0)
				goto err;
			if(!X509V3_EXT_print(bp, ex, cflag, 16))
				{
				BIO_printf(bp, "%16s", "");
				M_ASN1_OCTET_STRING_print(bp,ex->value);
				}
			if (BIO_write(bp,"\n",1) <= 0) goto err;
			}
		}
	if (!(cflag & X509_FLAG_NO_EXTENSIONS))
		X509V3_extensions_print(bp, "X509v3 extensions",
					ci->extensions, cflag, 8);

	if(!(cflag & X509_FLAG_NO_SIGDUMP))
		{
+4 −4
Original line number Diff line number Diff line
@@ -22,11 +22,11 @@ TEST=
APPS=

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

SRC= $(LIBSRC)
+1 −1
Original line number Diff line number Diff line
@@ -510,7 +510,7 @@ 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);
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);
Loading