diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2000-12-14 18:42:28 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2000-12-14 18:42:28 +0000 |
commit | 2c15d426b927444652cb53f39bc8463a1e6b91a6 (patch) | |
tree | 9850785e8806f5b6ff8dd633e35c603ed333d235 /crypto/ocsp | |
parent | bdcfe1d165b46d9263d3395535631305c3e27bd6 (diff) | |
download | openssl-2c15d426b927444652cb53f39bc8463a1e6b91a6.tar.gz |
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.
Diffstat (limited to 'crypto/ocsp')
-rw-r--r-- | crypto/ocsp/Makefile.ssl | 8 | ||||
-rw-r--r-- | crypto/ocsp/ocsp.h | 2 | ||||
-rw-r--r-- | crypto/ocsp/ocsp_asn.c | 37 | ||||
-rw-r--r-- | crypto/ocsp/ocsp_lib.c | 79 | ||||
-rw-r--r-- | crypto/ocsp/ocsp_prn.c | 125 |
5 files changed, 167 insertions, 84 deletions
diff --git a/crypto/ocsp/Makefile.ssl b/crypto/ocsp/Makefile.ssl index cadaeba830..9387f34b7d 100644 --- a/crypto/ocsp/Makefile.ssl +++ b/crypto/ocsp/Makefile.ssl @@ -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) diff --git a/crypto/ocsp/ocsp.h b/crypto/ocsp/ocsp.h index 4807205a84..0ee8fdc827 100644 --- a/crypto/ocsp/ocsp.h +++ b/crypto/ocsp/ocsp.h @@ -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); diff --git a/crypto/ocsp/ocsp_asn.c b/crypto/ocsp/ocsp_asn.c index a61b0aed39..a84db660da 100644 --- a/crypto/ocsp/ocsp_asn.c +++ b/crypto/ocsp/ocsp_asn.c @@ -65,6 +65,8 @@ ASN1_SEQUENCE(OCSP_SIGNATURE) = { ASN1_SEQUENCE_OF(OCSP_SIGNATURE, certs, X509) } ASN1_SEQUENCE_END(OCSP_SIGNATURE); +IMPLEMENT_ASN1_FUNCTIONS(OCSP_SIGNATURE) + ASN1_SEQUENCE(OCSP_CERTID) = { ASN1_SIMPLE(OCSP_CERTID, hashAlgorithm, X509_ALGOR), ASN1_SIMPLE(OCSP_CERTID, issuerNameHash, ASN1_OCTET_STRING), @@ -72,11 +74,15 @@ ASN1_SEQUENCE(OCSP_CERTID) = { ASN1_SIMPLE(OCSP_CERTID, serialNumber, ASN1_INTEGER) } ASN1_SEQUENCE_END(OCSP_CERTID); +IMPLEMENT_ASN1_FUNCTIONS(OCSP_CERTID) + ASN1_SEQUENCE(OCSP_ONEREQ) = { ASN1_SIMPLE(OCSP_ONEREQ, reqCert, OCSP_CERTID), ASN1_EXP_SEQUENCE_OF_OPT(OCSP_ONEREQ, singleRequestExtensions, X509_EXTENSION, 0) } ASN1_SEQUENCE_END(OCSP_ONEREQ); +IMPLEMENT_ASN1_FUNCTIONS(OCSP_ONEREQ) + ASN1_SEQUENCE(OCSP_REQINFO) = { ASN1_EXP_OPT(OCSP_REQINFO, version, ASN1_INTEGER, 0), ASN1_EXP_OPT(OCSP_REQINFO, requestorName, GENERAL_NAME, 1), @@ -84,11 +90,14 @@ ASN1_SEQUENCE(OCSP_REQINFO) = { ASN1_EXP_SEQUENCE_OF_OPT(OCSP_REQINFO, requestExtensions, X509_EXTENSION, 2) } ASN1_SEQUENCE_END(OCSP_REQINFO); +IMPLEMENT_ASN1_FUNCTIONS(OCSP_REQINFO) + ASN1_SEQUENCE(OCSP_REQUEST) = { ASN1_SIMPLE(OCSP_REQUEST, tbsRequest, OCSP_REQINFO), ASN1_EXP_OPT(OCSP_REQUEST, optionalSignature, OCSP_SIGNATURE, 0) } ASN1_SEQUENCE_END(OCSP_REQUEST); +IMPLEMENT_ASN1_FUNCTIONS(OCSP_REQUEST) /* OCSP_RESPONSE templates */ @@ -97,11 +106,15 @@ ASN1_SEQUENCE(OCSP_RESPBYTES) = { ASN1_SIMPLE(OCSP_RESPBYTES, response, ASN1_OCTET_STRING) } ASN1_SEQUENCE_END(OCSP_RESPBYTES); +IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPBYTES) + ASN1_SEQUENCE(OCSP_RESPONSE) = { ASN1_SIMPLE(OCSP_RESPONSE, responseStatus, ASN1_ENUMERATED), ASN1_EXP_OPT(OCSP_RESPONSE, responseBytes, OCSP_RESPBYTES, 0) } ASN1_SEQUENCE_END(OCSP_RESPONSE); +IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPONSE) + ASN1_CHOICE(OCSP_RESPID) = { ASN1_EXP(OCSP_RESPID, value.byName, X509_NAME, 1), ASN1_IMP(OCSP_RESPID, value.byKey, ASN1_OCTET_STRING, 2) @@ -112,12 +125,16 @@ ASN1_SEQUENCE(OCSP_REVOKEDINFO) = { ASN1_EXP_OPT(OCSP_REVOKEDINFO, revocationReason, ASN1_ENUMERATED, 0) } ASN1_SEQUENCE_END(OCSP_REVOKEDINFO); +IMPLEMENT_ASN1_FUNCTIONS(OCSP_REVOKEDINFO) + ASN1_CHOICE(OCSP_CERTSTATUS) = { ASN1_IMP(OCSP_CERTSTATUS, value.good, ASN1_NULL, 0), ASN1_IMP(OCSP_CERTSTATUS, value.revoked, OCSP_REVOKEDINFO, 1), ASN1_IMP(OCSP_CERTSTATUS, value.unknown, ASN1_NULL, 2) } ASN1_CHOICE_END(OCSP_CERTSTATUS); +IMPLEMENT_ASN1_FUNCTIONS(OCSP_CERTSTATUS) + ASN1_SEQUENCE(OCSP_SINGLERESP) = { ASN1_SIMPLE(OCSP_SINGLERESP, certId, OCSP_CERTID), ASN1_SIMPLE(OCSP_SINGLERESP, certStatus, OCSP_CERTSTATUS), @@ -126,6 +143,8 @@ ASN1_SEQUENCE(OCSP_SINGLERESP) = { ASN1_EXP_SEQUENCE_OF_OPT(OCSP_SINGLERESP, singleExtensions, X509_EXTENSION, 1) } ASN1_SEQUENCE_END(OCSP_SINGLERESP); +IMPLEMENT_ASN1_FUNCTIONS(OCSP_SINGLERESP) + ASN1_SEQUENCE(OCSP_RESPDATA) = { ASN1_EXP_OPT(OCSP_RESPDATA, version, ASN1_INTEGER, 0), ASN1_SIMPLE(OCSP_RESPDATA, responderId, OCSP_RESPID), @@ -134,6 +153,8 @@ ASN1_SEQUENCE(OCSP_RESPDATA) = { ASN1_EXP_SEQUENCE_OF_OPT(OCSP_RESPDATA, responseExtensions, X509_EXTENSION, 1) } ASN1_SEQUENCE_END(OCSP_RESPDATA); +IMPLEMENT_ASN1_FUNCTIONS(OCSP_RESPDATA) + ASN1_SEQUENCE(OCSP_BASICRESP) = { ASN1_SIMPLE(OCSP_BASICRESP, tbsResponseData, OCSP_RESPDATA), ASN1_SIMPLE(OCSP_BASICRESP, signatureAlgorithm, X509_ALGOR), @@ -141,3 +162,19 @@ ASN1_SEQUENCE(OCSP_BASICRESP) = { ASN1_EXP_SEQUENCE_OF_OPT(OCSP_BASICRESP, certs, X509, 0) } ASN1_SEQUENCE_END(OCSP_BASICRESP); +IMPLEMENT_ASN1_FUNCTIONS(OCSP_BASICRESP) + +ASN1_SEQUENCE(OCSP_CRLID) = { + ASN1_EXP_OPT(OCSP_CRLID, crlUrl, ASN1_IA5STRING, 0), + ASN1_EXP_OPT(OCSP_CRLID, crlNum, ASN1_INTEGER, 1), + ASN1_EXP_OPT(OCSP_CRLID, crlTime, ASN1_GENERALIZEDTIME, 2) +} ASN1_SEQUENCE_END(OCSP_CRLID); + +IMPLEMENT_ASN1_FUNCTIONS(OCSP_CRLID) + +ASN1_SEQUENCE(OCSP_SERVICELOC) = { + ASN1_SIMPLE(OCSP_SERVICELOC, issuer, X509_NAME), + ASN1_SEQUENCE_OF(OCSP_SERVICELOC, locator, ACCESS_DESCRIPTION) +} ASN1_SEQUENCE_END(OCSP_SERVICELOC); + +IMPLEMENT_ASN1_FUNCTIONS(OCSP_SERVICELOC) diff --git a/crypto/ocsp/ocsp_lib.c b/crypto/ocsp/ocsp_lib.c index f633ca749b..6f810d584d 100644 --- a/crypto/ocsp/ocsp_lib.c +++ b/crypto/ocsp/ocsp_lib.c @@ -460,85 +460,6 @@ GENERAL_NAME *n; return 1; } - -int OCSP_REQUEST_print(bp, o) -BIO *bp; -OCSP_REQUEST* o; - { - int i,j,n; - long l; - char *s; - OCSP_CERTID* cid = NULL; - OCSP_ONEREQ *one = NULL; - OCSP_REQINFO *inf = o->tbsRequest; - OCSP_SIGNATURE *sig = o->optionalSignature; - - if (BIO_write(bp,"OCSP Request Data:\n",19) <= 0) goto err; - l=ASN1_INTEGER_get(inf->version); - if (BIO_printf(bp,"%4sVersion: %lu (0x%lx)","",l+1,l) <= 0) goto err; - if (inf->requestorName != NULL) - { - if (BIO_write(bp,"\n Requestor Name: ",21) <= 0) - goto err; - i2a_GENERAL_NAME(bp, inf->requestorName); - } - if (BIO_write(bp,"\n Requestor List:\n",21) <= 0) goto err; - for (i = 0; i < sk_OCSP_ONEREQ_num(inf->requestList); i++) - { - if (! sk_OCSP_ONEREQ_value(inf->requestList, i)) continue; - one = sk_OCSP_ONEREQ_value(inf->requestList, i); - cid = one->reqCert; - j=OBJ_obj2nid(cid->hashAlgorithm->algorithm); - if (BIO_printf(bp,"%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; - if (!BIO_write(bp,"\n",1)) goto err; - if (!OCSP_extensions_print(bp, one->singleRequestExtensions, - "Request Single Extensions")) - goto err; - } - if (!OCSP_extensions_print(bp, inf->requestExtensions, - "Request Extensions")) - goto err; - if (sig) - { - i=OBJ_obj2nid(sig->signatureAlgorithm->algorithm); - if (BIO_printf(bp,"OCSP Request Signature Algorithm: %s", - (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)) <= 0) - goto err; - n=sig->signature->length; - s=(char *)sig->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 (sig->certs) - { - for (i=0; i<sk_X509_num(sig->certs); i++) - if (sk_X509_value(sig->certs,i) != NULL) - X509_print(bp, - sk_X509_value(sig->certs,i)); - } - } - return 1; -err: - return 0; - } - int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o) { int i, j, n; diff --git a/crypto/ocsp/ocsp_prn.c b/crypto/ocsp/ocsp_prn.c new file mode 100644 index 0000000000..436f23e9e3 --- /dev/null +++ b/crypto/ocsp/ocsp_prn.c @@ -0,0 +1,125 @@ +/* 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 OCSP_CERTID_print(BIO *bp, OCSP_CERTID* a, int indent) + { + BIO_printf(bp, "%*sCertificate ID:\n", indent, ""); + indent += 2; + BIO_printf(bp, "%*sHash Algorithm: ", indent, ""); + i2a_ASN1_OBJECT(bp, a->hashAlgorithm->algorithm); + BIO_printf(bp, "\n%*sIssuer Name Hash: ", indent, ""); + i2a_ASN1_STRING(bp, a->issuerNameHash, V_ASN1_OCTET_STRING); + BIO_printf(bp, "\n%*sIssuer Key Hash: ", indent, ""); + i2a_ASN1_STRING(bp, a->issuerKeyHash, V_ASN1_OCTET_STRING); + BIO_printf(bp, "\n%*sSerial Number: ", indent, ""); + i2a_ASN1_INTEGER(bp, a->serialNumber); + BIO_printf(bp, "\n"); + return 1; + } + +int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* o, unsigned long flags) + { + int i; + long l; + OCSP_CERTID* cid = NULL; + OCSP_ONEREQ *one = NULL; + OCSP_REQINFO *inf = o->tbsRequest; + OCSP_SIGNATURE *sig = o->optionalSignature; + + if (BIO_write(bp,"OCSP Request Data:\n",19) <= 0) goto err; + l=ASN1_INTEGER_get(inf->version); + if (BIO_printf(bp,"%4sVersion: %lu (0x%lx)","",l+1,l) <= 0) goto err; + if (inf->requestorName != NULL) + { + if (BIO_write(bp,"\n Requestor Name: ",21) <= 0) + goto err; + GENERAL_NAME_print(bp, inf->requestorName); + } + if (BIO_write(bp,"\n Requestor List:\n",21) <= 0) goto err; + for (i = 0; i < sk_OCSP_ONEREQ_num(inf->requestList); i++) + { + if (!sk_OCSP_ONEREQ_value(inf->requestList, i)) continue; + one = sk_OCSP_ONEREQ_value(inf->requestList, i); + cid = one->reqCert; + OCSP_CERTID_print(bp, cid, 8); + if (!X509V3_extensions_print(bp, + "OCSP Request Single Extensions", + one->singleRequestExtensions, flags, 4)) + goto err; + } + if (!X509V3_extensions_print(bp, "OCSP Request Extensions", + inf->requestExtensions, flags, 4)) + goto err; + if (sig) + { + X509_signature_print(bp, sig->signatureAlgorithm, sig->signature); + } + return 1; +err: + return 0; + } |