summaryrefslogtreecommitdiff
path: root/src/crypto/rsa/blinding.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/crypto/rsa/blinding.c')
-rw-r--r--src/crypto/rsa/blinding.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/crypto/rsa/blinding.c b/src/crypto/rsa/blinding.c
index c93cee1b..d21633f8 100644
--- a/src/crypto/rsa/blinding.c
+++ b/src/crypto/rsa/blinding.c
@@ -127,9 +127,11 @@ struct bn_blinding_st {
BIGNUM *mod; /* just a reference */
int counter;
unsigned long flags;
- BN_MONT_CTX *m_ctx;
+ /* mont is the Montgomery context used for this |BN_BLINDING|. It is not
+ * owned and must outlive this structure. */
+ const BN_MONT_CTX *mont;
int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
- const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
+ const BIGNUM *m, BN_CTX *ctx, const BN_MONT_CTX *mont);
};
BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod) {
@@ -284,8 +286,8 @@ void BN_BLINDING_set_flags(BN_BLINDING *b, unsigned long flags) {
BN_BLINDING *BN_BLINDING_create_param(
BN_BLINDING *b, const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,
int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
- const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx),
- BN_MONT_CTX *m_ctx) {
+ const BIGNUM *m, BN_CTX *ctx, const BN_MONT_CTX *mont),
+ const BN_MONT_CTX *mont) {
int retry_counter = 32;
BN_BLINDING *ret = NULL;
@@ -317,8 +319,8 @@ BN_BLINDING *BN_BLINDING_create_param(
if (bn_mod_exp != NULL) {
ret->bn_mod_exp = bn_mod_exp;
}
- if (m_ctx != NULL) {
- ret->m_ctx = m_ctx;
+ if (mont != NULL) {
+ ret->mont = mont;
}
do {
@@ -343,8 +345,8 @@ BN_BLINDING *BN_BLINDING_create_param(
}
} while (1);
- if (ret->bn_mod_exp != NULL && ret->m_ctx != NULL) {
- if (!ret->bn_mod_exp(ret->A, ret->A, ret->e, ret->mod, ctx, ret->m_ctx)) {
+ if (ret->bn_mod_exp != NULL && ret->mont != NULL) {
+ if (!ret->bn_mod_exp(ret->A, ret->A, ret->e, ret->mod, ctx, ret->mont)) {
goto err;
}
} else {
@@ -434,8 +436,7 @@ BN_BLINDING *rsa_setup_blinding(RSA *rsa, BN_CTX *in_ctx) {
BN_with_flags(n, rsa->n, BN_FLG_CONSTTIME);
if (rsa->flags & RSA_FLAG_CACHE_PUBLIC) {
- mont_ctx =
- BN_MONT_CTX_set_locked(&rsa->_method_mod_n, &rsa->lock, rsa->n, ctx);
+ mont_ctx = BN_MONT_CTX_set_locked(&rsa->mont_n, &rsa->lock, rsa->n, ctx);
if (mont_ctx == NULL) {
goto err;
}