diff options
| author | beck <> | 2017-01-29 17:49:23 +0000 |
|---|---|---|
| committer | beck <> | 2017-01-29 17:49:23 +0000 |
| commit | d1f47bd292f36094480caa49ada36b99a69c59b0 (patch) | |
| tree | 1a54abba678898ee5270ae4f3404a50ee9a92eea /src/lib/libcrypto/rsa/rsa_ameth.c | |
| parent | f8c627888330b75c2eea8a3c27d0efe947a4f9da (diff) | |
| download | openbsd-d1f47bd292f36094480caa49ada36b99a69c59b0.tar.gz openbsd-d1f47bd292f36094480caa49ada36b99a69c59b0.tar.bz2 openbsd-d1f47bd292f36094480caa49ada36b99a69c59b0.zip | |
Send the function codes from the error functions to the bit bucket,
as was done earlier in libssl. Thanks inoguchi@ for noticing
libssl had more reacharounds into this.
ok jsing@ inoguchi@
Diffstat (limited to 'src/lib/libcrypto/rsa/rsa_ameth.c')
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_ameth.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_ameth.c b/src/lib/libcrypto/rsa/rsa_ameth.c index aa911251cc..ec8a71b7b9 100644 --- a/src/lib/libcrypto/rsa/rsa_ameth.c +++ b/src/lib/libcrypto/rsa/rsa_ameth.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: rsa_ameth.c,v 1.17 2016/12/30 15:47:07 jsing Exp $ */ | 1 | /* $OpenBSD: rsa_ameth.c,v 1.18 2017/01/29 17:49:23 beck Exp $ */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2006. | 3 | * project 2006. |
| 4 | */ | 4 | */ |
| @@ -96,7 +96,7 @@ rsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) | |||
| 96 | if (!X509_PUBKEY_get0_param(NULL, &p, &pklen, NULL, pubkey)) | 96 | if (!X509_PUBKEY_get0_param(NULL, &p, &pklen, NULL, pubkey)) |
| 97 | return 0; | 97 | return 0; |
| 98 | if (!(rsa = d2i_RSAPublicKey(NULL, &p, pklen))) { | 98 | if (!(rsa = d2i_RSAPublicKey(NULL, &p, pklen))) { |
| 99 | RSAerr(RSA_F_RSA_PUB_DECODE, ERR_R_RSA_LIB); | 99 | RSAerror(ERR_R_RSA_LIB); |
| 100 | return 0; | 100 | return 0; |
| 101 | } | 101 | } |
| 102 | EVP_PKEY_assign_RSA (pkey, rsa); | 102 | EVP_PKEY_assign_RSA (pkey, rsa); |
| @@ -118,7 +118,7 @@ old_rsa_priv_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) | |||
| 118 | RSA *rsa; | 118 | RSA *rsa; |
| 119 | 119 | ||
| 120 | if (!(rsa = d2i_RSAPrivateKey (NULL, pder, derlen))) { | 120 | if (!(rsa = d2i_RSAPrivateKey (NULL, pder, derlen))) { |
| 121 | RSAerr(RSA_F_OLD_RSA_PRIV_DECODE, ERR_R_RSA_LIB); | 121 | RSAerror(ERR_R_RSA_LIB); |
| 122 | return 0; | 122 | return 0; |
| 123 | } | 123 | } |
| 124 | EVP_PKEY_assign_RSA(pkey, rsa); | 124 | EVP_PKEY_assign_RSA(pkey, rsa); |
| @@ -140,13 +140,13 @@ rsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) | |||
| 140 | rklen = i2d_RSAPrivateKey(pkey->pkey.rsa, &rk); | 140 | rklen = i2d_RSAPrivateKey(pkey->pkey.rsa, &rk); |
| 141 | 141 | ||
| 142 | if (rklen <= 0) { | 142 | if (rklen <= 0) { |
| 143 | RSAerr(RSA_F_RSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE); | 143 | RSAerror(ERR_R_MALLOC_FAILURE); |
| 144 | return 0; | 144 | return 0; |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(NID_rsaEncryption), 0, | 147 | if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(NID_rsaEncryption), 0, |
| 148 | V_ASN1_NULL, NULL, rk, rklen)) { | 148 | V_ASN1_NULL, NULL, rk, rklen)) { |
| 149 | RSAerr(RSA_F_RSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE); | 149 | RSAerror(ERR_R_MALLOC_FAILURE); |
| 150 | return 0; | 150 | return 0; |
| 151 | } | 151 | } |
| 152 | 152 | ||
| @@ -216,7 +216,7 @@ do_rsa_print(BIO *bp, const RSA *x, int off, int priv) | |||
| 216 | 216 | ||
| 217 | m = malloc(buf_len + 10); | 217 | m = malloc(buf_len + 10); |
| 218 | if (m == NULL) { | 218 | if (m == NULL) { |
| 219 | RSAerr(RSA_F_DO_RSA_PRINT, ERR_R_MALLOC_FAILURE); | 219 | RSAerror(ERR_R_MALLOC_FAILURE); |
| 220 | goto err; | 220 | goto err; |
| 221 | } | 221 | } |
| 222 | 222 | ||
| @@ -450,7 +450,7 @@ rsa_item_verify(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, | |||
| 450 | 450 | ||
| 451 | /* Sanity check: make sure it is PSS */ | 451 | /* Sanity check: make sure it is PSS */ |
| 452 | if (OBJ_obj2nid(sigalg->algorithm) != NID_rsassaPss) { | 452 | if (OBJ_obj2nid(sigalg->algorithm) != NID_rsassaPss) { |
| 453 | RSAerr(RSA_F_RSA_ITEM_VERIFY, RSA_R_UNSUPPORTED_SIGNATURE_TYPE); | 453 | RSAerror(RSA_R_UNSUPPORTED_SIGNATURE_TYPE); |
| 454 | return -1; | 454 | return -1; |
| 455 | } | 455 | } |
| 456 | 456 | ||
| @@ -458,25 +458,22 @@ rsa_item_verify(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, | |||
| 458 | pss = rsa_pss_decode(sigalg, &maskHash); | 458 | pss = rsa_pss_decode(sigalg, &maskHash); |
| 459 | 459 | ||
| 460 | if (pss == NULL) { | 460 | if (pss == NULL) { |
| 461 | RSAerr(RSA_F_RSA_ITEM_VERIFY, RSA_R_INVALID_PSS_PARAMETERS); | 461 | RSAerror(RSA_R_INVALID_PSS_PARAMETERS); |
| 462 | goto err; | 462 | goto err; |
| 463 | } | 463 | } |
| 464 | /* Check mask and lookup mask hash algorithm */ | 464 | /* Check mask and lookup mask hash algorithm */ |
| 465 | if (pss->maskGenAlgorithm) { | 465 | if (pss->maskGenAlgorithm) { |
| 466 | if (OBJ_obj2nid(pss->maskGenAlgorithm->algorithm) != NID_mgf1) { | 466 | if (OBJ_obj2nid(pss->maskGenAlgorithm->algorithm) != NID_mgf1) { |
| 467 | RSAerr(RSA_F_RSA_ITEM_VERIFY, | 467 | RSAerror(RSA_R_UNSUPPORTED_MASK_ALGORITHM); |
| 468 | RSA_R_UNSUPPORTED_MASK_ALGORITHM); | ||
| 469 | goto err; | 468 | goto err; |
| 470 | } | 469 | } |
| 471 | if (!maskHash) { | 470 | if (!maskHash) { |
| 472 | RSAerr(RSA_F_RSA_ITEM_VERIFY, | 471 | RSAerror(RSA_R_UNSUPPORTED_MASK_PARAMETER); |
| 473 | RSA_R_UNSUPPORTED_MASK_PARAMETER); | ||
| 474 | goto err; | 472 | goto err; |
| 475 | } | 473 | } |
| 476 | mgf1md = EVP_get_digestbyobj(maskHash->algorithm); | 474 | mgf1md = EVP_get_digestbyobj(maskHash->algorithm); |
| 477 | if (mgf1md == NULL) { | 475 | if (mgf1md == NULL) { |
| 478 | RSAerr(RSA_F_RSA_ITEM_VERIFY, | 476 | RSAerror(RSA_R_UNKNOWN_MASK_DIGEST); |
| 479 | RSA_R_UNKNOWN_MASK_DIGEST); | ||
| 480 | goto err; | 477 | goto err; |
| 481 | } | 478 | } |
| 482 | } else | 479 | } else |
| @@ -485,7 +482,7 @@ rsa_item_verify(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, | |||
| 485 | if (pss->hashAlgorithm) { | 482 | if (pss->hashAlgorithm) { |
| 486 | md = EVP_get_digestbyobj(pss->hashAlgorithm->algorithm); | 483 | md = EVP_get_digestbyobj(pss->hashAlgorithm->algorithm); |
| 487 | if (md == NULL) { | 484 | if (md == NULL) { |
| 488 | RSAerr(RSA_F_RSA_ITEM_VERIFY, RSA_R_UNKNOWN_PSS_DIGEST); | 485 | RSAerror(RSA_R_UNKNOWN_PSS_DIGEST); |
| 489 | goto err; | 486 | goto err; |
| 490 | } | 487 | } |
| 491 | } else | 488 | } else |
| @@ -498,8 +495,7 @@ rsa_item_verify(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, | |||
| 498 | * RSA routines will trap other invalid values anyway. | 495 | * RSA routines will trap other invalid values anyway. |
| 499 | */ | 496 | */ |
| 500 | if (saltlen < 0) { | 497 | if (saltlen < 0) { |
| 501 | RSAerr(RSA_F_RSA_ITEM_VERIFY, | 498 | RSAerror(RSA_R_INVALID_SALT_LENGTH); |
| 502 | RSA_R_INVALID_SALT_LENGTH); | ||
| 503 | goto err; | 499 | goto err; |
| 504 | } | 500 | } |
| 505 | } else | 501 | } else |
| @@ -509,7 +505,7 @@ rsa_item_verify(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, | |||
| 509 | * and PKCS#1 says we should reject any other value anyway. | 505 | * and PKCS#1 says we should reject any other value anyway. |
| 510 | */ | 506 | */ |
| 511 | if (pss->trailerField && ASN1_INTEGER_get(pss->trailerField) != 1) { | 507 | if (pss->trailerField && ASN1_INTEGER_get(pss->trailerField) != 1) { |
| 512 | RSAerr(RSA_F_RSA_ITEM_VERIFY, RSA_R_INVALID_TRAILER); | 508 | RSAerror(RSA_R_INVALID_TRAILER); |
| 513 | goto err; | 509 | goto err; |
| 514 | } | 510 | } |
| 515 | 511 | ||
