diff options
author | Rich Salz <rsalz@openssl.org> | 2015-04-30 21:37:06 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2015-04-30 21:37:06 -0400 |
commit | 23a1d5e97cd543d2b8e1b01dbf0f619b2e5ce540 (patch) | |
tree | 2d9372864fc2b34939d21b3706768ec225c9548f /crypto/rsa/rsa_eay.c | |
parent | 34166d41892643a36ad2d1f53cc0025e2edc2a39 (diff) | |
download | openssl-23a1d5e97cd543d2b8e1b01dbf0f619b2e5ce540.tar.gz |
free NULL cleanup 7
This gets BN_.*free:
BN_BLINDING_free BN_CTX_free BN_FLG_FREE BN_GENCB_free
BN_MONT_CTX_free BN_RECP_CTX_free BN_clear_free BN_free BUF_MEM_free
Also fix a call to DSA_SIG_free to ccgost engine and remove some #ifdef'd
dead code in engines/e_ubsec.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/rsa/rsa_eay.c')
-rw-r--r-- | crypto/rsa/rsa_eay.c | 77 |
1 files changed, 27 insertions, 50 deletions
diff --git a/crypto/rsa/rsa_eay.c b/crypto/rsa/rsa_eay.c index 49c157a842..5b8e21b7a5 100644 --- a/crypto/rsa/rsa_eay.c +++ b/crypto/rsa/rsa_eay.c @@ -239,10 +239,9 @@ static int RSA_eay_public_encrypt(int flen, const unsigned char *from, r = num; err: - if (ctx != NULL) { + if (ctx != NULL) BN_CTX_end(ctx); - BN_CTX_free(ctx); - } + BN_CTX_free(ctx); OPENSSL_clear_free(buf, num); return (r); } @@ -434,19 +433,16 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from, if (rsa->flags & RSA_FLAG_CACHE_PUBLIC) if (!BN_MONT_CTX_set_locked (&rsa->_method_mod_n, CRYPTO_LOCK_RSA, rsa->n, ctx)) { - if (local_d) - BN_free(local_d); + BN_free(local_d); goto err; } if (!rsa->meth->bn_mod_exp(ret, f, d, rsa->n, ctx, rsa->_method_mod_n)) { - if (local_d) - BN_free(local_d); + BN_free(local_d); goto err; } - if (local_d) - BN_free(local_d); + BN_free(local_d); } if (blinding) @@ -473,10 +469,9 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from, r = num; err: - if (ctx != NULL) { + if (ctx != NULL) BN_CTX_end(ctx); - BN_CTX_free(ctx); - } + BN_CTX_free(ctx); OPENSSL_clear_free(buf, num); return (r); } @@ -570,18 +565,15 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from, if (rsa->flags & RSA_FLAG_CACHE_PUBLIC) if (!BN_MONT_CTX_set_locked (&rsa->_method_mod_n, CRYPTO_LOCK_RSA, rsa->n, ctx)) { - if (local_d) - BN_free(local_d); + BN_free(local_d); goto err; } if (!rsa->meth->bn_mod_exp(ret, f, d, rsa->n, ctx, rsa->_method_mod_n)) { - if (local_d) - BN_free(local_d); + BN_free(local_d); goto err; } - if (local_d) - BN_free(local_d); + BN_free(local_d); } if (blinding) @@ -612,10 +604,9 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from, RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT, RSA_R_PADDING_CHECK_FAILED); err: - if (ctx != NULL) { + if (ctx != NULL) BN_CTX_end(ctx); - BN_CTX_free(ctx); - } + BN_CTX_free(ctx); OPENSSL_clear_free(buf, num); return (r); } @@ -712,10 +703,9 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from, RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT, RSA_R_PADDING_CHECK_FAILED); err: - if (ctx != NULL) { + if (ctx != NULL) BN_CTX_end(ctx); - BN_CTX_free(ctx); - } + BN_CTX_free(ctx); OPENSSL_clear_free(buf, num); return (r); } @@ -769,17 +759,13 @@ static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) (&rsa->_method_mod_p, CRYPTO_LOCK_RSA, p, ctx) || !BN_MONT_CTX_set_locked(&rsa->_method_mod_q, CRYPTO_LOCK_RSA, q, ctx)) { - if (local_p) - BN_free(local_p); - if (local_q) - BN_free(local_q); + BN_free(local_p); + BN_free(local_q); goto err; } } - if (local_p) - BN_free(local_p); - if (local_q) - BN_free(local_q); + BN_free(local_p); + BN_free(local_q); } if (rsa->flags & RSA_FLAG_CACHE_PUBLIC) @@ -900,25 +886,19 @@ static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) d = rsa->d; if (!rsa->meth->bn_mod_exp(r0, I, d, rsa->n, ctx, rsa->_method_mod_n)) { - if (local_d) - BN_free(local_d); + BN_free(local_d); goto err; } - if (local_d) - BN_free(local_d); + BN_free(local_d); } } ret = 1; err: - if (local_dmp1) - BN_free(local_dmp1); - if (local_dmq1) - BN_free(local_dmq1); - if (local_c) - BN_free(local_c); - if (local_r1) - BN_free(local_r1); + BN_free(local_dmp1); + BN_free(local_dmq1); + BN_free(local_c); + BN_free(local_r1); BN_CTX_end(ctx); return (ret); } @@ -931,12 +911,9 @@ static int RSA_eay_init(RSA *rsa) static int RSA_eay_finish(RSA *rsa) { - if (rsa->_method_mod_n != NULL) - BN_MONT_CTX_free(rsa->_method_mod_n); - if (rsa->_method_mod_p != NULL) - BN_MONT_CTX_free(rsa->_method_mod_p); - if (rsa->_method_mod_q != NULL) - BN_MONT_CTX_free(rsa->_method_mod_q); + BN_MONT_CTX_free(rsa->_method_mod_n); + BN_MONT_CTX_free(rsa->_method_mod_p); + BN_MONT_CTX_free(rsa->_method_mod_q); return (1); } |