summaryrefslogtreecommitdiffstats
path: root/crypto/asn1/t_x509.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>1999-01-17 00:13:14 +0000
committerDr. Stephen Henson <steve@openssl.org>1999-01-17 00:13:14 +0000
commitf6aed2cda608d6291225030fc259f207aac33732 (patch)
tree871e34a38284841b02131a1ad2725485a99a1ecc /crypto/asn1/t_x509.c
parentc3ae9a4851463e083e1b5dd803a286a61f2b784b (diff)
Time to blow up the source tree :-) This is the beginning of support for
GeneralizedTime. At several points PKIX specifies that GeneralizedTime can be used but OpenSSL doesn't currently support it. This patch adds several files and a bunch of functions. Of interest is the ASN1_TIME structure and its related functions. At several points certificates, CRLs et al specify that a time can be expressed as a choice of UTCTime and GeneralizedTime. Currently OpenSSL interprets this (wrongly) as UTCTime because GeneralizedTime isn't supported. The ASN1_TIME stuff provides this functionality. Still todo is to trace which cert and CRL points need an ASN1_TIME and modify the utilities appropriately and of course fix all the bugs. Note new OpenSSL copyright in the new file a_time.c. I didn't put it in a_gentm.c because it is a minimally modified form a_utctm.c . Since this adds new files and error codes you will need to do a 'make errors' at the top level to add the new codes.
Diffstat (limited to 'crypto/asn1/t_x509.c')
-rw-r--r--crypto/asn1/t_x509.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/crypto/asn1/t_x509.c b/crypto/asn1/t_x509.c
index 4bf1bd4536..bfee6f66a7 100644
--- a/crypto/asn1/t_x509.c
+++ b/crypto/asn1/t_x509.c
@@ -291,6 +291,57 @@ ASN1_STRING *v;
return(1);
}
+int ASN1_TIME_print(bp, tm)
+BIO *bp;
+ASN1_TIME *tm;
+{
+ if(tm->type == V_ASN1_UTCTIME) return ASN1_UTCTIME_print(bp, tm);
+ if(tm->type == V_ASN1_GENERALIZEDTIME)
+ return ASN1_GENERALIZEDTIME_print(bp, tm);
+ BIO_write(bp,"Bad time value",14);
+ return(0);
+}
+
+
+int ASN1_GENERALIZEDTIME_print(bp,tm)
+BIO *bp;
+ASN1_GENERALIZEDTIME *tm;
+ {
+ char *v;
+ int gmt=0;
+ static char *mon[12]={
+ "Jan","Feb","Mar","Apr","May","Jun",
+ "Jul","Aug","Sep","Oct","Nov","Dec"};
+ int i;
+ int y=0,M=0,d=0,h=0,m=0,s=0;
+
+ i=tm->length;
+ v=(char *)tm->data;
+
+ if (i < 12) goto err;
+ if (v[i-1] == 'Z') gmt=1;
+ for (i=0; i<12; i++)
+ if ((v[i] > '9') || (v[i] < '0')) goto err;
+ y= (v[0]-'0')*1000+(v[1]-'0')*100 + (v[2]-'0')*10+(v[3]-'0');
+ M= (v[4]-'0')*10+(v[5]-'0');
+ if ((M > 12) || (M < 1)) goto err;
+ d= (v[6]-'0')*10+(v[7]-'0');
+ h= (v[8]-'0')*10+(v[9]-'0');
+ m= (v[10]-'0')*10+(v[11]-'0');
+ if ( (v[12] >= '0') && (v[12] <= '9') &&
+ (v[13] >= '0') && (v[13] <= '9'))
+ s= (v[12]-'0')*10+(v[13]-'0');
+
+ if (BIO_printf(bp,"%s %2d %02d:%02d:%02d %d%s",
+ mon[M-1],d,h,m,s,y,(gmt)?" GMT":"") <= 0)
+ return(0);
+ else
+ return(1);
+err:
+ BIO_write(bp,"Bad time value",14);
+ return(0);
+ }
+
int ASN1_UTCTIME_print(bp,tm)
BIO *bp;
ASN1_UTCTIME *tm;