Redo OCSP response printing. Remove duplicate or
obsolete code. Delete some redundant files.
This commit is contained in:
parent
959f67d6a4
commit
1f47ec53a2
@ -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 \
|
||||
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 \
|
||||
ocsp_lib.o ocsp_prn.o ocsp_err.o
|
||||
#ocsp_v3.o
|
||||
LIBSRC= ocsp_asn.c ocsp_ext.c \
|
||||
ocsp_lib.c ocsp_prn.c ocsp_err.c
|
||||
|
||||
LIBOBJ= ocsp_asn.o ocsp_ext.o \
|
||||
ocsp_lib.o ocsp_prn.o ocsp_err.o
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
|
@ -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_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.
|
||||
|
@ -1,82 +0,0 @@
|
||||
/* 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;
|
||||
}
|
@ -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(>, &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;
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* ocsp_cid.c */
|
||||
/* ocsp_prn.c */
|
||||
/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
|
||||
* project. */
|
||||
|
||||
@ -64,9 +64,9 @@
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/ocsp.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/pem.h>
|
||||
|
||||
int OCSP_CERTID_print(BIO *bp, OCSP_CERTID* a, int indent)
|
||||
static int ocsp_certid_print(BIO *bp, OCSP_CERTID* a, int indent)
|
||||
{
|
||||
BIO_printf(bp, "%*sCertificate ID:\n", indent, "");
|
||||
indent += 2;
|
||||
@ -82,6 +82,56 @@ int OCSP_CERTID_print(BIO *bp, OCSP_CERTID* a, int indent)
|
||||
return 1;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
long t;
|
||||
char *m;
|
||||
} OCSP_TBLSTR;
|
||||
|
||||
static char *table2string(long s, OCSP_TBLSTR *ts, int len)
|
||||
{
|
||||
OCSP_TBLSTR *p;
|
||||
for (p=ts; p < ts + len; p++)
|
||||
if (p->t == s)
|
||||
return p->m;
|
||||
return "(UNKNOWN)";
|
||||
}
|
||||
|
||||
static char* ocspResponseStatus2string(long s)
|
||||
{
|
||||
static OCSP_TBLSTR rstat_tbl[] = {
|
||||
{ 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" } };
|
||||
return table2string(s, rstat_tbl, 6);
|
||||
}
|
||||
|
||||
static char* ocspCertStatus2string(long s)
|
||||
{
|
||||
static OCSP_TBLSTR cstat_tbl[] = {
|
||||
{ V_OCSP_CERTSTATUS_GOOD, "good" },
|
||||
{ V_OCSP_CERTSTATUS_REVOKED, "revoked" },
|
||||
{ V_OCSP_CERTSTATUS_UNKNOWN, "unknown" } };
|
||||
return table2string(s, cstat_tbl, 3);
|
||||
}
|
||||
|
||||
static char * cRLReason2string(long s)
|
||||
{
|
||||
OCSP_TBLSTR reason_tbl[] = {
|
||||
{ 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" } };
|
||||
return table2string(s, reason_tbl, 8);
|
||||
}
|
||||
|
||||
int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* o, unsigned long flags)
|
||||
{
|
||||
int i;
|
||||
@ -93,7 +143,7 @@ int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* o, unsigned long flags)
|
||||
|
||||
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 (BIO_printf(bp," Version: %lu (0x%lx)",l+1,l) <= 0) goto err;
|
||||
if (inf->requestorName != NULL)
|
||||
{
|
||||
if (BIO_write(bp,"\n Requestor Name: ",21) <= 0)
|
||||
@ -106,7 +156,7 @@ int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* o, unsigned long flags)
|
||||
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);
|
||||
ocsp_certid_print(bp, cid, 8);
|
||||
if (!X509V3_extensions_print(bp,
|
||||
"OCSP Request Single Extensions",
|
||||
one->singleRequestExtensions, flags, 4))
|
||||
@ -119,6 +169,121 @@ int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST* o, unsigned long flags)
|
||||
{
|
||||
X509_signature_print(bp, sig->signatureAlgorithm, sig->signature);
|
||||
}
|
||||
|
||||
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));
|
||||
PEM_write_bio_X509(bp,sk_X509_value(sig->certs,i));
|
||||
}
|
||||
return 1;
|
||||
err:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags)
|
||||
{
|
||||
int i;
|
||||
long l;
|
||||
unsigned char *p;
|
||||
OCSP_CERTID *cid = NULL;
|
||||
OCSP_BASICRESP *br = NULL;
|
||||
OCSP_RESPID *rid = NULL;
|
||||
OCSP_RESPDATA *rd = NULL;
|
||||
OCSP_CERTSTATUS *cst = NULL;
|
||||
OCSP_REVOKEDINFO *rev = NULL;
|
||||
OCSP_SINGLERESP *single = NULL;
|
||||
OCSP_RESPBYTES *rb = o->responseBytes;
|
||||
|
||||
if (BIO_puts(bp,"OCSP Response Data:\n") <= 0) goto err;
|
||||
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;
|
||||
if (BIO_puts(bp," Response Type: ") <= 0)
|
||||
goto err;
|
||||
if(i2a_ASN1_OBJECT(bp, rb->responseType) <= 0)
|
||||
goto err;
|
||||
if (OBJ_obj2nid(rb->responseType) != NID_id_pkix_OCSP_basic)
|
||||
{
|
||||
BIO_puts(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,"\n Version: %lu (0x%lx)\n",
|
||||
l+1,l) <= 0) goto err;
|
||||
if (BIO_puts(bp," Responder Id: ") <= 0) goto err;
|
||||
|
||||
rid = rd->responderId;
|
||||
switch (rid->type)
|
||||
{
|
||||
case V_OCSP_RESPID_NAME:
|
||||
X509_NAME_print_ex(bp, rid->value.byName, 0, XN_FLAG_ONELINE);
|
||||
break;
|
||||
case V_OCSP_RESPID_KEY:
|
||||
i2a_ASN1_STRING(bp, rid->value.byKey, V_ASN1_OCTET_STRING);
|
||||
break;
|
||||
}
|
||||
|
||||
if (BIO_printf(bp,"\n Produced At: ")<=0) goto err;
|
||||
if (!ASN1_GENERALIZEDTIME_print(bp, rd->producedAt)) goto err;
|
||||
if (BIO_printf(bp,"\n 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;
|
||||
if(ocsp_certid_print(bp, cid, 4) <= 0) goto err;
|
||||
cst = single->certStatus;
|
||||
if (BIO_printf(bp,"\n Cert Status: %s",
|
||||
ocspCertStatus2string(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 (!X509V3_extensions_print(bp,
|
||||
"OCSP Basic Response Single Extensions",
|
||||
single->singleExtensions, flags, 4))
|
||||
goto err;
|
||||
}
|
||||
if (!X509V3_extensions_print(bp, "OCSP Basic Response Extensions",
|
||||
rd->responseExtensions, flags, 4))
|
||||
if(X509_signature_print(bp, br->signatureAlgorithm, br->signature) <= 0)
|
||||
goto err;
|
||||
|
||||
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;
|
||||
|
@ -1,124 +0,0 @@
|
||||
/* ocsp_req.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/asn1.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/ocsp.h>
|
||||
#include <openssl/x509v3.h>
|
||||
|
||||
int i2a_OCSP_REQINFO(BIO *bp,
|
||||
OCSP_REQINFO* a)
|
||||
{
|
||||
int i, j=1;
|
||||
if (a->version == NULL) BIO_puts(bp, "0");
|
||||
else i2a_ASN1_INTEGER(bp, a->version);
|
||||
if (a->requestorName != NULL)
|
||||
{
|
||||
j++;
|
||||
#ifdef UNDEF
|
||||
i2a_GENERAL_NAME(bp, a->requestorName); /* does not exist */
|
||||
#endif
|
||||
}
|
||||
if (a->requestList != NULL)
|
||||
{
|
||||
for (i=0; i<sk_OCSP_ONEREQ_num(a->requestList); i++)
|
||||
if (sk_OCSP_ONEREQ_value(a->requestList,i) != NULL)
|
||||
i2a_OCSP_ONEREQ(bp,
|
||||
sk_OCSP_ONEREQ_value(a->requestList,i));
|
||||
j+=sk_OCSP_ONEREQ_num(a->requestList);
|
||||
}
|
||||
j+=OCSP_extensions_print(bp, a->requestExtensions,
|
||||
"Request Extensions");
|
||||
return j;
|
||||
}
|
||||
|
||||
int i2a_OCSP_REQUEST(BIO *bp,
|
||||
OCSP_REQUEST* a)
|
||||
{
|
||||
i2a_OCSP_REQINFO(bp, a->tbsRequest);
|
||||
i2a_OCSP_SIGNATURE(bp, a->optionalSignature);
|
||||
return a->optionalSignature ? 2 : 1;
|
||||
}
|
||||
|
||||
int i2a_OCSP_ONEREQ(BIO *bp,
|
||||
OCSP_ONEREQ* a)
|
||||
{
|
||||
i2a_OCSP_CERTID(bp, a->reqCert);
|
||||
#ifdef UNDEF
|
||||
/* XXX need generic extension print method or need to register
|
||||
* ocsp extensions with existing extension handler mechanism,
|
||||
* invoke i2a callbacks.
|
||||
*/
|
||||
if (a->singleRequestExtensions != NULL)
|
||||
{
|
||||
for (i=0; i<sk_X509_EXTENSION_num(a->singleRequestExtensions); i++)
|
||||
if (sk_X509_EXTENSION_value(a->singleRequestExtensions,i) != NULL)
|
||||
i2a_X509_EXTENSION(bp,
|
||||
sk_X509_EXTENSION_value(
|
||||
a->singleRequestExtensions, i));
|
||||
j+=sk_X509_EXTENSION_num(a->singleRequestExtensions);
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
@ -1,232 +0,0 @@
|
||||
/* ocsp_req.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/err.h>
|
||||
#include <openssl/objects.h>
|
||||
#include <openssl/asn1.h>
|
||||
#include <openssl/ocsp.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/x509v3.h>
|
||||
|
||||
int i2a_OCSP_RESPBYTES(BIO *bp,
|
||||
OCSP_RESPBYTES* a)
|
||||
{
|
||||
i2a_ASN1_OBJECT(bp, a->responseType);
|
||||
i2a_ASN1_STRING(bp, a->response, V_ASN1_OCTET_STRING);
|
||||
return 2;
|
||||
}
|
||||
|
||||
int i2a_OCSP_RESPONSE(BIO *bp, OCSP_RESPONSE* a)
|
||||
{
|
||||
i2a_ASN1_STRING(bp, a->responseStatus, V_ASN1_ENUMERATED);
|
||||
i2a_OCSP_RESPBYTES(bp, a->responseBytes);
|
||||
return a->responseBytes ? 2 : 1;
|
||||
}
|
||||
|
||||
int i2a_OCSP_RESPID(BIO *bp, OCSP_RESPID* a)
|
||||
{
|
||||
switch (a->type)
|
||||
{
|
||||
case V_OCSP_RESPID_NAME:
|
||||
X509_NAME_print(bp, a->value.byName, 16);
|
||||
break;
|
||||
case V_OCSP_RESPID_KEY:
|
||||
i2a_ASN1_STRING(bp, a->value.byKey, V_ASN1_OCTET_STRING);
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int i2a_OCSP_RESPDATA(BIO *bp, OCSP_RESPDATA* a)
|
||||
{
|
||||
int i, j=2;
|
||||
if (a->version == NULL) BIO_puts(bp, "0");
|
||||
else i2a_ASN1_INTEGER(bp, a->version);
|
||||
i2a_OCSP_RESPID(bp, a->responderId);
|
||||
if (!ASN1_GENERALIZEDTIME_print(bp, a->producedAt)) return 0;
|
||||
if (a->responses != NULL)
|
||||
{
|
||||
for (i=0; i<sk_OCSP_SINGLERESP_num(a->responses); i++)
|
||||
if (sk_OCSP_SINGLERESP_value(a->responses,i) != NULL)
|
||||
i2a_OCSP_SINGLERESP(bp,
|
||||
sk_OCSP_SINGLERESP_value(a->responses,i));
|
||||
j+=sk_OCSP_SINGLERESP_num(a->responses);
|
||||
}
|
||||
#ifdef UNDEF
|
||||
/* XXX need generic extension print method or need to register
|
||||
* ocsp extensions with existing extension handler mechanism,
|
||||
* invoke i2a callbacks.
|
||||
*/
|
||||
if (a->responseExtensions != NULL)
|
||||
{
|
||||
for (i=0; i<sk_X509_EXTENSION_num(a->responseExtensions); i++)
|
||||
if (sk_X509_EXTENSION_value(a->responseExtensions,i) != NULL)
|
||||
i2a_X509_EXTENSION(bp,
|
||||
sk_X509_EXTENSION_value(a->responseExtensions,i));
|
||||
j+=sk_X509_EXTENSION_num(a->responseExtensions);
|
||||
}
|
||||
#endif
|
||||
return j;
|
||||
}
|
||||
|
||||
int i2a_OCSP_BASICRESP(BIO *bp, OCSP_BASICRESP* a)
|
||||
{
|
||||
int i, j=3;
|
||||
i2a_OCSP_RESPDATA(bp, a->tbsResponseData);
|
||||
#ifdef UNDEF
|
||||
/* XXX this guy isn't implemented. */
|
||||
i2a_X509_ALGOR(bp, a->signatureAlgorithm);
|
||||
#else /* instead, just show OID, not param */
|
||||
i2a_ASN1_OBJECT(bp, a->signatureAlgorithm->algorithm);
|
||||
#endif
|
||||
i2a_ASN1_STRING(bp, a->signature, V_ASN1_BIT_STRING);
|
||||
if (a->certs != NULL)
|
||||
{
|
||||
for (i=0; i<sk_X509_num(a->certs); i++)
|
||||
if (sk_X509_value(a->certs,i) != NULL)
|
||||
X509_print(bp, sk_X509_value(a->certs,i));
|
||||
j+=sk_X509_num(a->certs);
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
int i2a_OCSP_REVOKEDINFO(BIO *bp, OCSP_REVOKEDINFO* a)
|
||||
{
|
||||
int i=0;
|
||||
if (!ASN1_GENERALIZEDTIME_print(bp, a->revocationTime)) return 0;
|
||||
if (a->revocationReason)
|
||||
{
|
||||
i2a_ASN1_STRING(bp, a->revocationReason, V_ASN1_ENUMERATED);
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
int i2a_OCSP_CERTSTATUS(BIO *bp, OCSP_CERTSTATUS* a)
|
||||
{
|
||||
switch (a->type)
|
||||
{
|
||||
case V_OCSP_CERTSTATUS_GOOD:
|
||||
BIO_puts(bp, "CertStatus: good");
|
||||
break;
|
||||
case V_OCSP_CERTSTATUS_REVOKED:
|
||||
BIO_puts(bp, "CertStatus: revoked");
|
||||
i2a_OCSP_REVOKEDINFO(bp, a->value.revoked);
|
||||
break;
|
||||
case V_OCSP_CERTSTATUS_UNKNOWN:
|
||||
BIO_puts(bp, "CertStatus: unknown");
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int i2a_OCSP_SINGLERESP(BIO *bp, OCSP_SINGLERESP* a)
|
||||
{
|
||||
int /* XXX i, */ j=3;
|
||||
i2a_OCSP_CERTID(bp, a->certId);
|
||||
i2a_OCSP_CERTSTATUS(bp, a->certStatus);
|
||||
if (!ASN1_GENERALIZEDTIME_print(bp, a->thisUpdate)) return 0;
|
||||
if (a->nextUpdate)
|
||||
{
|
||||
if (!ASN1_GENERALIZEDTIME_print(bp, a->nextUpdate)) return 0;
|
||||
j++;
|
||||
}
|
||||
#ifdef UNDEF
|
||||
/* XXX need generic extension print method or need to register
|
||||
* ocsp extensions with existing extension handler mechanism,
|
||||
* invoke i2a callbacks.
|
||||
*/
|
||||
if (a->singleExtensions != NULL)
|
||||
{
|
||||
for (i=0; i<sk_X509_EXTENSION_num(a->singleExtensions); i++)
|
||||
if (sk_X509_EXTENSION_value(a->singleExtensions,i) != NULL)
|
||||
i2a_X509_EXTENSION(bp,
|
||||
sk_X509_EXTENSION_value(a->singleExtensions,i));
|
||||
j+=sk_X509_EXTENSION_num(a->singleExtensions);
|
||||
}
|
||||
#endif
|
||||
return j;
|
||||
}
|
||||
|
||||
int i2a_OCSP_CRLID(BIO *bp, OCSP_CRLID* a)
|
||||
{
|
||||
int i = 0;
|
||||
char buf[1024];
|
||||
if (a->crlUrl && ASN1_STRING_print(bp, (ASN1_STRING*)a->crlUrl)) i++;
|
||||
if (a->crlNum && a2i_ASN1_INTEGER(bp, a->crlNum, buf, sizeof buf)) i++;
|
||||
if (a->crlTime && ASN1_GENERALIZEDTIME_print(bp, a->crlTime)) i++;
|
||||
return i;
|
||||
}
|
||||
|
||||
int i2a_OCSP_SERVICELOC(BIO *bp,
|
||||
OCSP_SERVICELOC* a)
|
||||
{
|
||||
int i;
|
||||
X509_NAME_print(bp, a->issuer, 16);
|
||||
if (!a->locator) return 1;
|
||||
for (i=0; i<sk_ACCESS_DESCRIPTION_num(a->locator); i++)
|
||||
i2a_ACCESS_DESCRIPTION(bp,
|
||||
sk_ACCESS_DESCRIPTION_value(a->locator,i));
|
||||
return i+2;
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
/* ocsp_sig.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/asn1.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/ocsp.h>
|
||||
#include <openssl/x509.h>
|
||||
|
||||
int i2a_OCSP_SIGNATURE(BIO *bp,
|
||||
OCSP_SIGNATURE* a)
|
||||
{
|
||||
int i, j=2;
|
||||
#ifdef UNDEF
|
||||
/* XXX this guy isn't implemented. */
|
||||
i2a_X509_ALGOR(bp, a->signatureAlgorithm);
|
||||
#else /* instead, just show OID, not param */
|
||||
i2a_ASN1_OBJECT(bp, a->signatureAlgorithm->algorithm);
|
||||
#endif
|
||||
i2a_ASN1_STRING(bp, a->signature, V_ASN1_BIT_STRING);
|
||||
if (a->certs != NULL)
|
||||
{
|
||||
for (i=0; i<sk_X509_num(a->certs); i++)
|
||||
if (sk_X509_value(a->certs,i) != NULL)
|
||||
X509_print(bp, sk_X509_value(a->certs,i));
|
||||
j+=sk_X509_num(a->certs);
|
||||
}
|
||||
return j;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user