aboutsummaryrefslogtreecommitdiff
path: root/crypto/rsa/rsa_eay.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2005-04-26 23:58:54 +0000
committerDr. Stephen Henson <steve@openssl.org>2005-04-26 23:58:54 +0000
commit6ec8e63af6c1835a8b222350dbabf7bb2ace094f (patch)
treef1d18170d6f7d197f5cc721beac9c49531c363f6 /crypto/rsa/rsa_eay.c
parent465b9f6b26e0ea9181cff7a55dcc69b3fc1291fe (diff)
downloadopenssl-6ec8e63af6c1835a8b222350dbabf7bb2ace094f.zip
openssl-6ec8e63af6c1835a8b222350dbabf7bb2ace094f.tar.gz
openssl-6ec8e63af6c1835a8b222350dbabf7bb2ace094f.tar.bz2
Port BN_MONT_CTX_set_locked() from stable branch.
The function rsa_eay_mont_helper() has been removed because it is no longer needed after this change.
Diffstat (limited to 'crypto/rsa/rsa_eay.c')
-rw-r--r--crypto/rsa/rsa_eay.c31
1 files changed, 2 insertions, 29 deletions
diff --git a/crypto/rsa/rsa_eay.c b/crypto/rsa/rsa_eay.c
index 6bf681f..738ea0b 100644
--- a/crypto/rsa/rsa_eay.c
+++ b/crypto/rsa/rsa_eay.c
@@ -97,40 +97,13 @@ const RSA_METHOD *RSA_PKCS1_SSLeay(void)
return(&rsa_pkcs1_eay_meth);
}
-/* Static helper to reduce oodles of code duplication. As a slight
- * optimisation, the "MONT_HELPER() macro must be used as front-end to this
- * function, to prevent unnecessary function calls - there is an initial test
- * that is performed by the macro-generated code. */
-static int rsa_eay_mont_helper(BN_MONT_CTX **ptr, const BIGNUM *modulus, BN_CTX *ctx)
- {
- BN_MONT_CTX *bn_mont_ctx;
- if((bn_mont_ctx = BN_MONT_CTX_new()) == NULL)
- return 0;
- if(!BN_MONT_CTX_set(bn_mont_ctx, modulus, ctx))
- {
- BN_MONT_CTX_free(bn_mont_ctx);
- return 0;
- }
- if (*ptr == NULL) /* other thread may have finished first */
- {
- CRYPTO_w_lock(CRYPTO_LOCK_RSA);
- if (*ptr == NULL) /* check again in the lock to stop races */
- {
- *ptr = bn_mont_ctx;
- bn_mont_ctx = NULL;
- }
- CRYPTO_w_unlock(CRYPTO_LOCK_RSA);
- }
- if (bn_mont_ctx)
- BN_MONT_CTX_free(bn_mont_ctx);
- return 1;
- }
/* Usage example;
* MONT_HELPER(rsa, bn_ctx, p, rsa->flags & RSA_FLAG_CACHE_PRIVATE, goto err);
*/
#define MONT_HELPER(rsa, ctx, m, pre_cond, err_instr) \
if((pre_cond) && ((rsa)->_method_mod_##m == NULL) && \
- !rsa_eay_mont_helper(&((rsa)->_method_mod_##m), \
+ !BN_MONT_CTX_set_locked(&((rsa)->_method_mod_##m), \
+ CRYPTO_LOCK_RSA, \
(rsa)->m, (ctx))) \
err_instr