From de487514aeb2a43fefe0d9c7cf697ff4f5e9be5f Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Thu, 14 Dec 2000 00:53:10 +0000 Subject: [PATCH] New function X509_signature_print() to remove some duplicate code from certificate, CRL and request printing routines. --- CHANGES | 4 ++++ crypto/asn1/t_crl.c | 15 +-------------- crypto/asn1/t_req.c | 21 ++------------------- crypto/asn1/t_x509.c | 37 ++++++++++++++++++++++--------------- crypto/x509/x509.h | 2 ++ 5 files changed, 31 insertions(+), 48 deletions(-) diff --git a/CHANGES b/CHANGES index 3efb236f63..ad71e3d721 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,10 @@ Changes between 0.9.6 and 0.9.7 [xx XXX 2000] + *) New function X509_signature_print() to remove duplication in some + print routines. + [Steve Henson] + *) Add a special meaning when SET OF and SEQUENCE OF flags are both set (this was treated exactly the same as SET OF previously). This is used to reorder the STACK representing the structure to match the diff --git a/crypto/asn1/t_crl.c b/crypto/asn1/t_crl.c index d78e4a8f88..3a1443386d 100644 --- a/crypto/asn1/t_crl.c +++ b/crypto/asn1/t_crl.c @@ -86,7 +86,6 @@ int X509_CRL_print_fp(FILE *fp, X509_CRL *x) int X509_CRL_print(BIO *out, X509_CRL *x) { char buf[256]; - unsigned char *s; STACK_OF(X509_REVOKED) *rev; X509_REVOKED *r; long l; @@ -131,19 +130,7 @@ int X509_CRL_print(BIO *out, X509_CRL *x) for(j = 0; j < X509_REVOKED_get_ext_count(r); j++) ext_print(out, X509_REVOKED_get_ext(r, j)); } - - i=OBJ_obj2nid(x->sig_alg->algorithm); - BIO_printf(out," Signature Algorithm: %s", - (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)); - - s = x->signature->data; - n = x->signature->length; - for (i=0; isig_alg, x->signature); return 1; diff --git a/crypto/asn1/t_req.c b/crypto/asn1/t_req.c index b80ea1857f..5e875b2f87 100644 --- a/crypto/asn1/t_req.c +++ b/crypto/asn1/t_req.c @@ -85,8 +85,7 @@ int X509_REQ_print_fp(FILE *fp, X509_REQ *x) int X509_REQ_print(BIO *bp, X509_REQ *x) { unsigned long l; - int i,n; - char *s; + int i; const char *neg; X509_REQ_INFO *ri; EVP_PKEY *pkey; @@ -226,24 +225,8 @@ get_next: sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free); } - i=OBJ_obj2nid(x->sig_alg->algorithm); - sprintf(str,"%4sSignature Algorithm: %s","", - (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)); - if (BIO_puts(bp,str) <= 0) goto err; + if(!X509_signature_print(bp, x->sig_alg, x->signature)) goto err; - n=x->signature->length; - s=(char *)x->signature->data; - for (i=0; isig_alg->algorithm); - if (BIO_printf(bp,"%4sSignature Algorithm: %s","", - (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)) <= 0) goto err; - - n=x->signature->length; - s=(char *)x->signature->data; - for (i=0; isig_alg, x->signature) <= 0) goto err; } if(!(cflag & X509_FLAG_NO_AUX)) { @@ -332,6 +319,26 @@ err: return(0); } +int X509_signature_print(BIO *bp, X509_ALGOR *sigalg, ASN1_STRING *sig) +{ + unsigned char *s; + int i, n; + if (BIO_puts(bp," Signature Algorithm: ") <= 0) return 0; + if (i2a_ASN1_OBJECT(bp, sigalg->algorithm) <= 0) return 0; + + n=sig->length; + s=sig->data; + for (i=0; i