diff options
Diffstat (limited to 'src/lib/libcrypto/pem/pem_info.c')
-rw-r--r-- | src/lib/libcrypto/pem/pem_info.c | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/lib/libcrypto/pem/pem_info.c b/src/lib/libcrypto/pem/pem_info.c index 191e3b5b10..f02aaa8bb4 100644 --- a/src/lib/libcrypto/pem/pem_info.c +++ b/src/lib/libcrypto/pem/pem_info.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: pem_info.c,v 1.21 2015/09/10 15:56:25 jsing Exp $ */ | 1 | /* $OpenBSD: pem_info.c,v 1.22 2017/01/29 17:49:23 beck Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -83,7 +83,7 @@ PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, | |||
83 | STACK_OF(X509_INFO) *ret; | 83 | STACK_OF(X509_INFO) *ret; |
84 | 84 | ||
85 | if ((b = BIO_new(BIO_s_file())) == NULL) { | 85 | if ((b = BIO_new(BIO_s_file())) == NULL) { |
86 | PEMerr(PEM_F_PEM_X509_INFO_READ, ERR_R_BUF_LIB); | 86 | PEMerror(ERR_R_BUF_LIB); |
87 | return (0); | 87 | return (0); |
88 | } | 88 | } |
89 | BIO_set_fp(b, fp, BIO_NOCLOSE); | 89 | BIO_set_fp(b, fp, BIO_NOCLOSE); |
@@ -109,8 +109,7 @@ PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, | |||
109 | 109 | ||
110 | if (sk == NULL) { | 110 | if (sk == NULL) { |
111 | if ((ret = sk_X509_INFO_new_null()) == NULL) { | 111 | if ((ret = sk_X509_INFO_new_null()) == NULL) { |
112 | PEMerr(PEM_F_PEM_X509_INFO_READ_BIO, | 112 | PEMerror(ERR_R_MALLOC_FAILURE); |
113 | ERR_R_MALLOC_FAILURE); | ||
114 | return 0; | 113 | return 0; |
115 | } | 114 | } |
116 | } else | 115 | } else |
@@ -249,13 +248,11 @@ start: | |||
249 | if (ptype) { | 248 | if (ptype) { |
250 | if (!d2i_PrivateKey(ptype, pp, &p, | 249 | if (!d2i_PrivateKey(ptype, pp, &p, |
251 | len)) { | 250 | len)) { |
252 | PEMerr(PEM_F_PEM_X509_INFO_READ_BIO, | 251 | PEMerror(ERR_R_ASN1_LIB); |
253 | ERR_R_ASN1_LIB); | ||
254 | goto err; | 252 | goto err; |
255 | } | 253 | } |
256 | } else if (d2i(pp, &p, len) == NULL) { | 254 | } else if (d2i(pp, &p, len) == NULL) { |
257 | PEMerr(PEM_F_PEM_X509_INFO_READ_BIO, | 255 | PEMerror(ERR_R_ASN1_LIB); |
258 | ERR_R_ASN1_LIB); | ||
259 | goto err; | 256 | goto err; |
260 | } | 257 | } |
261 | } else { /* encrypted RSA data */ | 258 | } else { /* encrypted RSA data */ |
@@ -323,8 +320,7 @@ PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc, | |||
323 | if (enc != NULL) { | 320 | if (enc != NULL) { |
324 | objstr = OBJ_nid2sn(EVP_CIPHER_nid(enc)); | 321 | objstr = OBJ_nid2sn(EVP_CIPHER_nid(enc)); |
325 | if (objstr == NULL) { | 322 | if (objstr == NULL) { |
326 | PEMerr(PEM_F_PEM_X509_INFO_WRITE_BIO, | 323 | PEMerror(PEM_R_UNSUPPORTED_CIPHER); |
327 | PEM_R_UNSUPPORTED_CIPHER); | ||
328 | goto err; | 324 | goto err; |
329 | } | 325 | } |
330 | } | 326 | } |
@@ -337,8 +333,7 @@ PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc, | |||
337 | if (xi->x_pkey != NULL) { | 333 | if (xi->x_pkey != NULL) { |
338 | if ((xi->enc_data != NULL) && (xi->enc_len > 0) ) { | 334 | if ((xi->enc_data != NULL) && (xi->enc_len > 0) ) { |
339 | if (enc == NULL) { | 335 | if (enc == NULL) { |
340 | PEMerr(PEM_F_PEM_X509_INFO_WRITE_BIO, | 336 | PEMerror(PEM_R_CIPHER_IS_NULL); |
341 | PEM_R_CIPHER_IS_NULL); | ||
342 | goto err; | 337 | goto err; |
343 | } | 338 | } |
344 | 339 | ||
@@ -355,16 +350,14 @@ PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc, | |||
355 | objstr = OBJ_nid2sn( | 350 | objstr = OBJ_nid2sn( |
356 | EVP_CIPHER_nid(xi->enc_cipher.cipher)); | 351 | EVP_CIPHER_nid(xi->enc_cipher.cipher)); |
357 | if (objstr == NULL) { | 352 | if (objstr == NULL) { |
358 | PEMerr(PEM_F_PEM_X509_INFO_WRITE_BIO, | 353 | PEMerror(PEM_R_UNSUPPORTED_CIPHER); |
359 | PEM_R_UNSUPPORTED_CIPHER); | ||
360 | goto err; | 354 | goto err; |
361 | } | 355 | } |
362 | 356 | ||
363 | /* create the right magic header stuff */ | 357 | /* create the right magic header stuff */ |
364 | if (strlen(objstr) + 23 + 2 * enc->iv_len + 13 > | 358 | if (strlen(objstr) + 23 + 2 * enc->iv_len + 13 > |
365 | sizeof buf) { | 359 | sizeof buf) { |
366 | PEMerr(PEM_F_PEM_X509_INFO_WRITE_BIO, | 360 | PEMerror(ASN1_R_BUFFER_TOO_SMALL); |
367 | ASN1_R_BUFFER_TOO_SMALL); | ||
368 | goto err; | 361 | goto err; |
369 | } | 362 | } |
370 | buf[0] = '\0'; | 363 | buf[0] = '\0'; |