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/dsa/dsa_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/dsa/dsa_ameth.c')
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_ameth.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_ameth.c b/src/lib/libcrypto/dsa/dsa_ameth.c index b589d39892..92f543de9e 100644 --- a/src/lib/libcrypto/dsa/dsa_ameth.c +++ b/src/lib/libcrypto/dsa/dsa_ameth.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: dsa_ameth.c,v 1.22 2017/01/21 10:38:29 beck Exp $ */ | 1 | /* $OpenBSD: dsa_ameth.c,v 1.23 2017/01/29 17:49:22 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 | */ |
| @@ -92,26 +92,26 @@ dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) | |||
| 92 | pmlen = pstr->length; | 92 | pmlen = pstr->length; |
| 93 | 93 | ||
| 94 | if (!(dsa = d2i_DSAparams(NULL, &pm, pmlen))) { | 94 | if (!(dsa = d2i_DSAparams(NULL, &pm, pmlen))) { |
| 95 | DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_DECODE_ERROR); | 95 | DSAerror(DSA_R_DECODE_ERROR); |
| 96 | goto err; | 96 | goto err; |
| 97 | } | 97 | } |
| 98 | } else if (ptype == V_ASN1_NULL || ptype == V_ASN1_UNDEF) { | 98 | } else if (ptype == V_ASN1_NULL || ptype == V_ASN1_UNDEF) { |
| 99 | if (!(dsa = DSA_new())) { | 99 | if (!(dsa = DSA_new())) { |
| 100 | DSAerr(DSA_F_DSA_PUB_DECODE, ERR_R_MALLOC_FAILURE); | 100 | DSAerror(ERR_R_MALLOC_FAILURE); |
| 101 | goto err; | 101 | goto err; |
| 102 | } | 102 | } |
| 103 | } else { | 103 | } else { |
| 104 | DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_PARAMETER_ENCODING_ERROR); | 104 | DSAerror(DSA_R_PARAMETER_ENCODING_ERROR); |
| 105 | goto err; | 105 | goto err; |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | if (!(public_key=d2i_ASN1_INTEGER(NULL, &p, pklen))) { | 108 | if (!(public_key=d2i_ASN1_INTEGER(NULL, &p, pklen))) { |
| 109 | DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_DECODE_ERROR); | 109 | DSAerror(DSA_R_DECODE_ERROR); |
| 110 | goto err; | 110 | goto err; |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | if (!(dsa->pub_key = ASN1_INTEGER_to_BN(public_key, NULL))) { | 113 | if (!(dsa->pub_key = ASN1_INTEGER_to_BN(public_key, NULL))) { |
| 114 | DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_BN_DECODE_ERROR); | 114 | DSAerror(DSA_R_BN_DECODE_ERROR); |
| 115 | goto err; | 115 | goto err; |
| 116 | } | 116 | } |
| 117 | 117 | ||
| @@ -141,12 +141,12 @@ dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) | |||
| 141 | 141 | ||
| 142 | str = ASN1_STRING_new(); | 142 | str = ASN1_STRING_new(); |
| 143 | if (str == NULL) { | 143 | if (str == NULL) { |
| 144 | DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE); | 144 | DSAerror(ERR_R_MALLOC_FAILURE); |
| 145 | goto err; | 145 | goto err; |
| 146 | } | 146 | } |
| 147 | str->length = i2d_DSAparams(dsa, &str->data); | 147 | str->length = i2d_DSAparams(dsa, &str->data); |
| 148 | if (str->length <= 0) { | 148 | if (str->length <= 0) { |
| 149 | DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE); | 149 | DSAerror(ERR_R_MALLOC_FAILURE); |
| 150 | ASN1_STRING_free(str); | 150 | ASN1_STRING_free(str); |
| 151 | goto err; | 151 | goto err; |
| 152 | } | 152 | } |
| @@ -160,7 +160,7 @@ dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) | |||
| 160 | penclen = i2d_DSAPublicKey(dsa, &penc); | 160 | penclen = i2d_DSAPublicKey(dsa, &penc); |
| 161 | 161 | ||
| 162 | if (penclen <= 0) { | 162 | if (penclen <= 0) { |
| 163 | DSAerr(DSA_F_DSA_PUB_ENCODE, ERR_R_MALLOC_FAILURE); | 163 | DSAerror(ERR_R_MALLOC_FAILURE); |
| 164 | goto err; | 164 | goto err; |
| 165 | } | 165 | } |
| 166 | 166 | ||
| @@ -211,21 +211,21 @@ dsa_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8) | |||
| 211 | goto decerr; | 211 | goto decerr; |
| 212 | /* We have parameters now set private key */ | 212 | /* We have parameters now set private key */ |
| 213 | if (!(dsa->priv_key = ASN1_INTEGER_to_BN(privkey, NULL))) { | 213 | if (!(dsa->priv_key = ASN1_INTEGER_to_BN(privkey, NULL))) { |
| 214 | DSAerr(DSA_F_DSA_PRIV_DECODE,DSA_R_BN_ERROR); | 214 | DSAerror(DSA_R_BN_ERROR); |
| 215 | goto dsaerr; | 215 | goto dsaerr; |
| 216 | } | 216 | } |
| 217 | /* Calculate public key */ | 217 | /* Calculate public key */ |
| 218 | if (!(dsa->pub_key = BN_new())) { | 218 | if (!(dsa->pub_key = BN_new())) { |
| 219 | DSAerr(DSA_F_DSA_PRIV_DECODE, ERR_R_MALLOC_FAILURE); | 219 | DSAerror(ERR_R_MALLOC_FAILURE); |
| 220 | goto dsaerr; | 220 | goto dsaerr; |
| 221 | } | 221 | } |
| 222 | if (!(ctx = BN_CTX_new())) { | 222 | if (!(ctx = BN_CTX_new())) { |
| 223 | DSAerr(DSA_F_DSA_PRIV_DECODE, ERR_R_MALLOC_FAILURE); | 223 | DSAerror(ERR_R_MALLOC_FAILURE); |
| 224 | goto dsaerr; | 224 | goto dsaerr; |
| 225 | } | 225 | } |
| 226 | 226 | ||
| 227 | if (!BN_mod_exp_ct(dsa->pub_key, dsa->g, dsa->priv_key, dsa->p, ctx)) { | 227 | if (!BN_mod_exp_ct(dsa->pub_key, dsa->g, dsa->priv_key, dsa->p, ctx)) { |
| 228 | DSAerr(DSA_F_DSA_PRIV_DECODE,DSA_R_BN_ERROR); | 228 | DSAerror(DSA_R_BN_ERROR); |
| 229 | goto dsaerr; | 229 | goto dsaerr; |
| 230 | } | 230 | } |
| 231 | 231 | ||
| @@ -236,7 +236,7 @@ dsa_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8) | |||
| 236 | goto done; | 236 | goto done; |
| 237 | 237 | ||
| 238 | decerr: | 238 | decerr: |
| 239 | DSAerr(DSA_F_DSA_PRIV_DECODE, DSA_R_DECODE_ERROR); | 239 | DSAerror(DSA_R_DECODE_ERROR); |
| 240 | dsaerr: | 240 | dsaerr: |
| 241 | DSA_free(dsa); | 241 | DSA_free(dsa); |
| 242 | done: | 242 | done: |
| @@ -255,13 +255,13 @@ dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) | |||
| 255 | 255 | ||
| 256 | params = ASN1_STRING_new(); | 256 | params = ASN1_STRING_new(); |
| 257 | if (!params) { | 257 | if (!params) { |
| 258 | DSAerr(DSA_F_DSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE); | 258 | DSAerror(ERR_R_MALLOC_FAILURE); |
| 259 | goto err; | 259 | goto err; |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | params->length = i2d_DSAparams(pkey->pkey.dsa, ¶ms->data); | 262 | params->length = i2d_DSAparams(pkey->pkey.dsa, ¶ms->data); |
| 263 | if (params->length <= 0) { | 263 | if (params->length <= 0) { |
| 264 | DSAerr(DSA_F_DSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE); | 264 | DSAerror(ERR_R_MALLOC_FAILURE); |
| 265 | goto err; | 265 | goto err; |
| 266 | } | 266 | } |
| 267 | params->type = V_ASN1_SEQUENCE; | 267 | params->type = V_ASN1_SEQUENCE; |
| @@ -269,7 +269,7 @@ dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) | |||
| 269 | /* Get private key into integer */ | 269 | /* Get private key into integer */ |
| 270 | prkey = BN_to_ASN1_INTEGER(pkey->pkey.dsa->priv_key, NULL); | 270 | prkey = BN_to_ASN1_INTEGER(pkey->pkey.dsa->priv_key, NULL); |
| 271 | if (!prkey) { | 271 | if (!prkey) { |
| 272 | DSAerr(DSA_F_DSA_PRIV_ENCODE, DSA_R_BN_ERROR); | 272 | DSAerror(DSA_R_BN_ERROR); |
| 273 | goto err; | 273 | goto err; |
| 274 | } | 274 | } |
| 275 | 275 | ||
| @@ -407,7 +407,7 @@ do_dsa_print(BIO *bp, const DSA *x, int off, int ptype) | |||
| 407 | 407 | ||
| 408 | m = malloc(buf_len + 10); | 408 | m = malloc(buf_len + 10); |
| 409 | if (m == NULL) { | 409 | if (m == NULL) { |
| 410 | DSAerr(DSA_F_DO_DSA_PRINT, ERR_R_MALLOC_FAILURE); | 410 | DSAerror(ERR_R_MALLOC_FAILURE); |
| 411 | goto err; | 411 | goto err; |
| 412 | } | 412 | } |
| 413 | 413 | ||
| @@ -441,7 +441,7 @@ dsa_param_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) | |||
| 441 | DSA *dsa; | 441 | DSA *dsa; |
| 442 | 442 | ||
| 443 | if (!(dsa = d2i_DSAparams(NULL, pder, derlen))) { | 443 | if (!(dsa = d2i_DSAparams(NULL, pder, derlen))) { |
| 444 | DSAerr(DSA_F_DSA_PARAM_DECODE, ERR_R_DSA_LIB); | 444 | DSAerror(ERR_R_DSA_LIB); |
| 445 | return 0; | 445 | return 0; |
| 446 | } | 446 | } |
| 447 | EVP_PKEY_assign_DSA(pkey, dsa); | 447 | EVP_PKEY_assign_DSA(pkey, dsa); |
| @@ -480,7 +480,7 @@ old_dsa_priv_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) | |||
| 480 | BIGNUM *j, *p1, *newp1; | 480 | BIGNUM *j, *p1, *newp1; |
| 481 | 481 | ||
| 482 | if (!(dsa = d2i_DSAPrivateKey(NULL, pder, derlen))) { | 482 | if (!(dsa = d2i_DSAPrivateKey(NULL, pder, derlen))) { |
| 483 | DSAerr(DSA_F_OLD_DSA_PRIV_DECODE, ERR_R_DSA_LIB); | 483 | DSAerror(ERR_R_DSA_LIB); |
| 484 | return 0; | 484 | return 0; |
| 485 | } | 485 | } |
| 486 | 486 | ||
| @@ -507,7 +507,7 @@ old_dsa_priv_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) | |||
| 507 | if (BN_mul(newp1, dsa->q, j, ctx) == 0) | 507 | if (BN_mul(newp1, dsa->q, j, ctx) == 0) |
| 508 | goto err; | 508 | goto err; |
| 509 | if (BN_cmp(newp1, p1) != 0) { | 509 | if (BN_cmp(newp1, p1) != 0) { |
| 510 | DSAerr(DSA_F_DSA_PARAM_DECODE, DSA_R_BAD_Q_VALUE); | 510 | DSAerror(DSA_R_BAD_Q_VALUE); |
| 511 | goto err; | 511 | goto err; |
| 512 | } | 512 | } |
| 513 | 513 | ||
| @@ -516,7 +516,7 @@ old_dsa_priv_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) | |||
| 516 | */ | 516 | */ |
| 517 | 517 | ||
| 518 | if (BN_is_prime_ex(dsa->q, BN_prime_checks, ctx, NULL) == 0) { | 518 | if (BN_is_prime_ex(dsa->q, BN_prime_checks, ctx, NULL) == 0) { |
| 519 | DSAerr(DSA_F_DSA_PARAM_DECODE, DSA_R_BAD_Q_VALUE); | 519 | DSAerror(DSA_R_BAD_Q_VALUE); |
| 520 | goto err; | 520 | goto err; |
| 521 | } | 521 | } |
| 522 | 522 | ||
| @@ -561,7 +561,7 @@ dsa_sig_print(BIO *bp, const X509_ALGOR *sigalg, const ASN1_STRING *sig, | |||
| 561 | update_buflen(dsa_sig->s, &buf_len); | 561 | update_buflen(dsa_sig->s, &buf_len); |
| 562 | m = malloc(buf_len + 10); | 562 | m = malloc(buf_len + 10); |
| 563 | if (m == NULL) { | 563 | if (m == NULL) { |
| 564 | DSAerr(DSA_F_DSA_SIG_PRINT, ERR_R_MALLOC_FAILURE); | 564 | DSAerror(ERR_R_MALLOC_FAILURE); |
| 565 | goto err; | 565 | goto err; |
| 566 | } | 566 | } |
| 567 | 567 | ||
