summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/t_x509.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/t_x509.c')
-rw-r--r--src/lib/libcrypto/asn1/t_x509.c64
1 files changed, 26 insertions, 38 deletions
diff --git a/src/lib/libcrypto/asn1/t_x509.c b/src/lib/libcrypto/asn1/t_x509.c
index 8f746f9c05..e061f2ffad 100644
--- a/src/lib/libcrypto/asn1/t_x509.c
+++ b/src/lib/libcrypto/asn1/t_x509.c
@@ -111,7 +111,6 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
111 ASN1_INTEGER *bs; 111 ASN1_INTEGER *bs;
112 EVP_PKEY *pkey=NULL; 112 EVP_PKEY *pkey=NULL;
113 const char *neg; 113 const char *neg;
114 ASN1_STRING *str=NULL;
115 114
116 if((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) { 115 if((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) {
117 mlch = '\n'; 116 mlch = '\n';
@@ -215,34 +214,10 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
215 ERR_print_errors(bp); 214 ERR_print_errors(bp);
216 } 215 }
217 else 216 else
218#ifndef OPENSSL_NO_RSA
219 if (pkey->type == EVP_PKEY_RSA)
220 {
221 BIO_printf(bp,"%12sRSA Public Key: (%d bit)\n","",
222 BN_num_bits(pkey->pkey.rsa->n));
223 RSA_print(bp,pkey->pkey.rsa,16);
224 }
225 else
226#endif
227#ifndef OPENSSL_NO_DSA
228 if (pkey->type == EVP_PKEY_DSA)
229 {
230 BIO_printf(bp,"%12sDSA Public Key:\n","");
231 DSA_print(bp,pkey->pkey.dsa,16);
232 }
233 else
234#endif
235#ifndef OPENSSL_NO_EC
236 if (pkey->type == EVP_PKEY_EC)
237 { 217 {
238 BIO_printf(bp, "%12sEC Public Key:\n",""); 218 EVP_PKEY_print_public(bp, pkey, 16, NULL);
239 EC_KEY_print(bp, pkey->pkey.ec, 16); 219 EVP_PKEY_free(pkey);
240 } 220 }
241 else
242#endif
243 BIO_printf(bp,"%12sUnknown Public Key:\n","");
244
245 EVP_PKEY_free(pkey);
246 } 221 }
247 222
248 if (!(cflag & X509_FLAG_NO_EXTENSIONS)) 223 if (!(cflag & X509_FLAG_NO_EXTENSIONS))
@@ -259,7 +234,6 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
259 } 234 }
260 ret=1; 235 ret=1;
261err: 236err:
262 if (str != NULL) ASN1_STRING_free(str);
263 if (m != NULL) OPENSSL_free(m); 237 if (m != NULL) OPENSSL_free(m);
264 return(ret); 238 return(ret);
265 } 239 }
@@ -329,14 +303,15 @@ int X509_signature_print(BIO *bp, X509_ALGOR *sigalg, ASN1_STRING *sig)
329 return 1; 303 return 1;
330} 304}
331 305
332int ASN1_STRING_print(BIO *bp, ASN1_STRING *v) 306int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v)
333 { 307 {
334 int i,n; 308 int i,n;
335 char buf[80],*p; 309 char buf[80];
310 const char *p;
336 311
337 if (v == NULL) return(0); 312 if (v == NULL) return(0);
338 n=0; 313 n=0;
339 p=(char *)v->data; 314 p=(const char *)v->data;
340 for (i=0; i<v->length; i++) 315 for (i=0; i<v->length; i++)
341 { 316 {
342 if ((p[i] > '~') || ((p[i] < ' ') && 317 if ((p[i] > '~') || ((p[i] < ' ') &&
@@ -358,7 +333,7 @@ int ASN1_STRING_print(BIO *bp, ASN1_STRING *v)
358 return(1); 333 return(1);
359 } 334 }
360 335
361int ASN1_TIME_print(BIO *bp, ASN1_TIME *tm) 336int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm)
362{ 337{
363 if(tm->type == V_ASN1_UTCTIME) return ASN1_UTCTIME_print(bp, tm); 338 if(tm->type == V_ASN1_UTCTIME) return ASN1_UTCTIME_print(bp, tm);
364 if(tm->type == V_ASN1_GENERALIZEDTIME) 339 if(tm->type == V_ASN1_GENERALIZEDTIME)
@@ -373,12 +348,14 @@ static const char *mon[12]=
373 "Jul","Aug","Sep","Oct","Nov","Dec" 348 "Jul","Aug","Sep","Oct","Nov","Dec"
374 }; 349 };
375 350
376int ASN1_GENERALIZEDTIME_print(BIO *bp, ASN1_GENERALIZEDTIME *tm) 351int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)
377 { 352 {
378 char *v; 353 char *v;
379 int gmt=0; 354 int gmt=0;
380 int i; 355 int i;
381 int y=0,M=0,d=0,h=0,m=0,s=0; 356 int y=0,M=0,d=0,h=0,m=0,s=0;
357 char *f = NULL;
358 int f_len = 0;
382 359
383 i=tm->length; 360 i=tm->length;
384 v=(char *)tm->data; 361 v=(char *)tm->data;
@@ -396,10 +373,21 @@ int ASN1_GENERALIZEDTIME_print(BIO *bp, ASN1_GENERALIZEDTIME *tm)
396 if (tm->length >= 14 && 373 if (tm->length >= 14 &&
397 (v[12] >= '0') && (v[12] <= '9') && 374 (v[12] >= '0') && (v[12] <= '9') &&
398 (v[13] >= '0') && (v[13] <= '9')) 375 (v[13] >= '0') && (v[13] <= '9'))
376 {
399 s= (v[12]-'0')*10+(v[13]-'0'); 377 s= (v[12]-'0')*10+(v[13]-'0');
378 /* Check for fractions of seconds. */
379 if (tm->length >= 15 && v[14] == '.')
380 {
381 int l = tm->length;
382 f = &v[14]; /* The decimal point. */
383 f_len = 1;
384 while (14 + f_len < l && f[f_len] >= '0' && f[f_len] <= '9')
385 ++f_len;
386 }
387 }
400 388
401 if (BIO_printf(bp,"%s %2d %02d:%02d:%02d %d%s", 389 if (BIO_printf(bp,"%s %2d %02d:%02d:%02d%.*s %d%s",
402 mon[M-1],d,h,m,s,y,(gmt)?" GMT":"") <= 0) 390 mon[M-1],d,h,m,s,f_len,f,y,(gmt)?" GMT":"") <= 0)
403 return(0); 391 return(0);
404 else 392 else
405 return(1); 393 return(1);
@@ -408,15 +396,15 @@ err:
408 return(0); 396 return(0);
409 } 397 }
410 398
411int ASN1_UTCTIME_print(BIO *bp, ASN1_UTCTIME *tm) 399int ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm)
412 { 400 {
413 char *v; 401 const char *v;
414 int gmt=0; 402 int gmt=0;
415 int i; 403 int i;
416 int y=0,M=0,d=0,h=0,m=0,s=0; 404 int y=0,M=0,d=0,h=0,m=0,s=0;
417 405
418 i=tm->length; 406 i=tm->length;
419 v=(char *)tm->data; 407 v=(const char *)tm->data;
420 408
421 if (i < 10) goto err; 409 if (i < 10) goto err;
422 if (v[i-1] == 'Z') gmt=1; 410 if (v[i-1] == 'Z') gmt=1;