warning.
[oweals/openssl.git] / crypto / asn1 / t_x509.c
index 1ab2caef19d7d966ea497b06bdc25c7f55d1621c..6ee1065ce9468c081f087d24dc3d2ecdf65c6e4f 100644 (file)
 
 #include <stdio.h>
 #include "cryptlib.h"
-#include "buffer.h"
-#include "bn.h"
+#include <openssl/buffer.h>
+#include <openssl/bn.h>
 #ifndef NO_RSA
-#include "rsa.h"
+#include <openssl/rsa.h>
 #endif
 #ifndef NO_DSA
-#include "dsa.h"
+#include <openssl/dsa.h>
 #endif
-#include "objects.h"
-#include "x509.h"
-#include "x509v3.h"
+#include <openssl/objects.h>
+#include <openssl/x509.h>
+#include <openssl/x509v3.h>
 
 #ifndef NO_FP_API
-int X509_print_fp(fp,x)
-FILE *fp;
-X509 *x;
+int X509_print_fp(FILE *fp, X509 *x)
         {
         BIO *b;
         int ret;
@@ -90,9 +88,7 @@ X509 *x;
         }
 #endif
 
-int X509_print(bp,x)
-BIO *bp;
-X509 *x;
+int X509_print(BIO *bp, X509 *x)
        {
        long l;
        int ret=0,i,j,n;
@@ -162,6 +158,7 @@ X509 *x;
        if (pkey == NULL)
                {
                BIO_printf(bp,"%12sUnable to load Public Key\n","");
+               ERR_print_errors(bp);
                }
        else
 #ifndef NO_RSA
@@ -191,11 +188,7 @@ X509 *x;
                BIO_printf(bp,"%8sX509v3 extensions:\n","");
                for (i=0; i<n; i++)
                        {
-#if 0
-                       int data_type,pack_type;
-#endif
                        ASN1_OBJECT *obj;
-
                        ex=X509_get_ext(x,i);
                        if (BIO_printf(bp,"%12s","") <= 0) goto err;
                        obj=X509_EXTENSION_get_object(ex);
@@ -206,7 +199,7 @@ X509 *x;
                        if(!X509V3_EXT_print(bp, ex, 0, 16))
                                {
                                BIO_printf(bp, "%16s", "");
-                               ASN1_OCTET_STRING_print(bp,ex->value);
+                               M_ASN1_OCTET_STRING_print(bp,ex->value);
                                }
                        if (BIO_write(bp,"\n",1) <= 0) goto err;
                        }
@@ -226,16 +219,15 @@ X509 *x;
                        ((i+1) == n)?"":":") <= 0) goto err;
                }
        if (BIO_write(bp,"\n",1) != 1) goto err;
+       if (!X509_CERT_AUX_print(bp, x->aux, 0)) goto err;
        ret=1;
 err:
        if (str != NULL) ASN1_STRING_free(str);
-       if (m != NULL) Free((char *)m);
+       if (m != NULL) Free(m);
        return(ret);
        }
 
-int ASN1_STRING_print(bp,v)
-BIO *bp;
-ASN1_STRING *v;
+int ASN1_STRING_print(BIO *bp, ASN1_STRING *v)
        {
        int i,n;
        char buf[80],*p;;
@@ -264,9 +256,7 @@ ASN1_STRING *v;
        return(1);
        }
 
-int ASN1_TIME_print(bp, tm)
-BIO *bp;
-ASN1_TIME *tm;
+int ASN1_TIME_print(BIO *bp, ASN1_TIME *tm)
 {
        if(tm->type == V_ASN1_UTCTIME) return ASN1_UTCTIME_print(bp, tm);
        if(tm->type == V_ASN1_GENERALIZEDTIME)
@@ -281,9 +271,7 @@ static const char *mon[12]=
     "Jul","Aug","Sep","Oct","Nov","Dec"
     };
 
-int ASN1_GENERALIZEDTIME_print(bp,tm)
-BIO *bp;
-ASN1_GENERALIZEDTIME *tm;
+int ASN1_GENERALIZEDTIME_print(BIO *bp, ASN1_GENERALIZEDTIME *tm)
        {
        char *v;
        int gmt=0;
@@ -317,9 +305,7 @@ err:
        return(0);
        }
 
-int ASN1_UTCTIME_print(bp,tm)
-BIO *bp;
-ASN1_UTCTIME *tm;
+int ASN1_UTCTIME_print(BIO *bp, ASN1_UTCTIME *tm)
        {
        char *v;
        int gmt=0;
@@ -354,10 +340,7 @@ err:
        return(0);
        }
 
-int X509_NAME_print(bp,name,obase)
-BIO *bp;
-X509_NAME *name;
-int obase;
+int X509_NAME_print(BIO *bp, X509_NAME *name, int obase)
        {
        char *s,*c;
        int ret=0,l,ll,i,first=1;
@@ -372,6 +355,7 @@ int obase;
        c=s;
        for (;;)
                {
+#ifndef CHARSET_EBCDIC
                if (    ((*s == '/') &&
                                ((s[1] >= 'A') && (s[1] <= 'Z') && (
                                        (s[2] == '=') ||
@@ -379,6 +363,15 @@ int obase;
                                        (s[3] == '='))
                                 ))) ||
                        (*s == '\0'))
+#else
+               if (    ((*s == '/') &&
+                               (isupper(s[1]) && (
+                                       (s[2] == '=') ||
+                                       (isupper(s[2]) &&
+                                       (s[3] == '='))
+                                ))) ||
+                       (*s == '\0'))
+#endif
                        {
                        if ((l <= 0) && !first)
                                {