diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/n_pkey.c')
| -rw-r--r-- | src/lib/libcrypto/asn1/n_pkey.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/lib/libcrypto/asn1/n_pkey.c b/src/lib/libcrypto/asn1/n_pkey.c index 1e73c82d09..d2fabf6e87 100644 --- a/src/lib/libcrypto/asn1/n_pkey.c +++ b/src/lib/libcrypto/asn1/n_pkey.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: n_pkey.c,v 1.30 2015/10/16 15:15:39 jsing Exp $ */ | 1 | /* $OpenBSD: n_pkey.c,v 1.31 2017/01/29 17:49:22 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 | * |
| @@ -260,7 +260,7 @@ i2d_RSA_NET(const RSA *a, unsigned char **pp, | |||
| 260 | 260 | ||
| 261 | /* Since its RC4 encrypted length is actual length */ | 261 | /* Since its RC4 encrypted length is actual length */ |
| 262 | if ((zz = malloc(rsalen)) == NULL) { | 262 | if ((zz = malloc(rsalen)) == NULL) { |
| 263 | ASN1err(ASN1_F_I2D_RSA_NET, ERR_R_MALLOC_FAILURE); | 263 | ASN1error(ERR_R_MALLOC_FAILURE); |
| 264 | goto err; | 264 | goto err; |
| 265 | } | 265 | } |
| 266 | 266 | ||
| @@ -269,12 +269,12 @@ i2d_RSA_NET(const RSA *a, unsigned char **pp, | |||
| 269 | i2d_RSAPrivateKey(a, &zz); | 269 | i2d_RSAPrivateKey(a, &zz); |
| 270 | 270 | ||
| 271 | if ((zz = malloc(pkeylen)) == NULL) { | 271 | if ((zz = malloc(pkeylen)) == NULL) { |
| 272 | ASN1err(ASN1_F_I2D_RSA_NET, ERR_R_MALLOC_FAILURE); | 272 | ASN1error(ERR_R_MALLOC_FAILURE); |
| 273 | goto err; | 273 | goto err; |
| 274 | } | 274 | } |
| 275 | 275 | ||
| 276 | if (!ASN1_STRING_set(enckey->os, "private-key", -1)) { | 276 | if (!ASN1_STRING_set(enckey->os, "private-key", -1)) { |
| 277 | ASN1err(ASN1_F_I2D_RSA_NET, ERR_R_MALLOC_FAILURE); | 277 | ASN1error(ERR_R_MALLOC_FAILURE); |
| 278 | goto err; | 278 | goto err; |
| 279 | } | 279 | } |
| 280 | enckey->enckey->digest->data = zz; | 280 | enckey->enckey->digest->data = zz; |
| @@ -287,7 +287,7 @@ i2d_RSA_NET(const RSA *a, unsigned char **pp, | |||
| 287 | cb = EVP_read_pw_string; | 287 | cb = EVP_read_pw_string; |
| 288 | i = cb((char *)buf, sizeof(buf), "Enter Private Key password:", 1); | 288 | i = cb((char *)buf, sizeof(buf), "Enter Private Key password:", 1); |
| 289 | if (i != 0) { | 289 | if (i != 0) { |
| 290 | ASN1err(ASN1_F_I2D_RSA_NET, ASN1_R_BAD_PASSWORD_READ); | 290 | ASN1error(ASN1_R_BAD_PASSWORD_READ); |
| 291 | goto err; | 291 | goto err; |
| 292 | } | 292 | } |
| 293 | i = strlen((char *)buf); | 293 | i = strlen((char *)buf); |
| @@ -340,19 +340,18 @@ d2i_RSA_NET(RSA **a, const unsigned char **pp, long length, | |||
| 340 | 340 | ||
| 341 | enckey = d2i_NETSCAPE_ENCRYPTED_PKEY(NULL, &p, length); | 341 | enckey = d2i_NETSCAPE_ENCRYPTED_PKEY(NULL, &p, length); |
| 342 | if (!enckey) { | 342 | if (!enckey) { |
| 343 | ASN1err(ASN1_F_D2I_RSA_NET, ASN1_R_DECODING_ERROR); | 343 | ASN1error(ASN1_R_DECODING_ERROR); |
| 344 | return NULL; | 344 | return NULL; |
| 345 | } | 345 | } |
| 346 | 346 | ||
| 347 | /* XXX 11 == strlen("private-key") */ | 347 | /* XXX 11 == strlen("private-key") */ |
| 348 | if (enckey->os->length != 11 || | 348 | if (enckey->os->length != 11 || |
| 349 | memcmp("private-key", enckey->os->data, 11) != 0) { | 349 | memcmp("private-key", enckey->os->data, 11) != 0) { |
| 350 | ASN1err(ASN1_F_D2I_RSA_NET, ASN1_R_PRIVATE_KEY_HEADER_MISSING); | 350 | ASN1error(ASN1_R_PRIVATE_KEY_HEADER_MISSING); |
| 351 | goto err; | 351 | goto err; |
| 352 | } | 352 | } |
| 353 | if (OBJ_obj2nid(enckey->enckey->algor->algorithm) != NID_rc4) { | 353 | if (OBJ_obj2nid(enckey->enckey->algor->algorithm) != NID_rc4) { |
| 354 | ASN1err(ASN1_F_D2I_RSA_NET, | 354 | ASN1error(ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM); |
| 355 | ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM); | ||
| 356 | goto err; | 355 | goto err; |
| 357 | } | 356 | } |
| 358 | if (cb == NULL) | 357 | if (cb == NULL) |
| @@ -384,7 +383,7 @@ d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os, | |||
| 384 | 383 | ||
| 385 | i=cb((char *)buf, sizeof(buf), "Enter Private Key password:",0); | 384 | i=cb((char *)buf, sizeof(buf), "Enter Private Key password:",0); |
| 386 | if (i != 0) { | 385 | if (i != 0) { |
| 387 | ASN1err(ASN1_F_D2I_RSA_NET_2, ASN1_R_BAD_PASSWORD_READ); | 386 | ASN1error(ASN1_R_BAD_PASSWORD_READ); |
| 388 | goto err; | 387 | goto err; |
| 389 | } | 388 | } |
| 390 | 389 | ||
| @@ -411,15 +410,14 @@ d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os, | |||
| 411 | zz = os->data; | 410 | zz = os->data; |
| 412 | 411 | ||
| 413 | if ((pkey = d2i_NETSCAPE_PKEY(NULL, &zz, os->length)) == NULL) { | 412 | if ((pkey = d2i_NETSCAPE_PKEY(NULL, &zz, os->length)) == NULL) { |
| 414 | ASN1err(ASN1_F_D2I_RSA_NET_2, | 413 | ASN1error(ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY); |
| 415 | ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY); | ||
| 416 | goto err; | 414 | goto err; |
| 417 | } | 415 | } |
| 418 | 416 | ||
| 419 | zz = pkey->private_key->data; | 417 | zz = pkey->private_key->data; |
| 420 | if ((ret = d2i_RSAPrivateKey(a, &zz, | 418 | if ((ret = d2i_RSAPrivateKey(a, &zz, |
| 421 | pkey->private_key->length)) == NULL) { | 419 | pkey->private_key->length)) == NULL) { |
| 422 | ASN1err(ASN1_F_D2I_RSA_NET_2, ASN1_R_UNABLE_TO_DECODE_RSA_KEY); | 420 | ASN1error(ASN1_R_UNABLE_TO_DECODE_RSA_KEY); |
| 423 | goto err; | 421 | goto err; |
| 424 | } | 422 | } |
| 425 | 423 | ||
