diff options
-rw-r--r-- | crypto/rsa/blinding.c | 46 | ||||
-rw-r--r-- | crypto/rsa/internal.h | 10 | ||||
-rw-r--r-- | crypto/rsa/rsa_impl.c | 4 |
3 files changed, 10 insertions, 50 deletions
diff --git a/crypto/rsa/blinding.c b/crypto/rsa/blinding.c index 5addddc0..d5bfcd31 100644 --- a/crypto/rsa/blinding.c +++ b/crypto/rsa/blinding.c @@ -113,7 +113,6 @@ #include <openssl/bn.h> #include <openssl/mem.h> #include <openssl/err.h> -#include <openssl/thread.h> #include "internal.h" @@ -126,7 +125,6 @@ struct bn_blinding_st { BIGNUM *e; BIGNUM *mod; /* just a reference */ int counter; - unsigned long flags; /* mont is the Montgomery context used for this |BN_BLINDING|. It is not * owned and must outlive this structure. */ const BN_MONT_CTX *mont; @@ -200,13 +198,12 @@ int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx) { b->counter = 0; } - if (++b->counter == BN_BLINDING_COUNTER && b->e != NULL && - !(b->flags & BN_BLINDING_NO_RECREATE)) { + if (++b->counter == BN_BLINDING_COUNTER && b->e != NULL) { /* re-create blinding parameters */ if (!BN_BLINDING_create_param(b, NULL, NULL, ctx, NULL, NULL)) { goto err; } - } else if (!(b->flags & BN_BLINDING_NO_UPDATE)) { + } else { if (!BN_mod_mul(b->A, b->A, b->A, b->mod, ctx)) { goto err; } @@ -225,10 +222,6 @@ err: } int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx) { - return BN_BLINDING_convert_ex(n, NULL, b, ctx); -} - -int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx) { int ret = 1; if (b->A == NULL || b->Ai == NULL) { @@ -243,12 +236,6 @@ int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx) { return 0; } - if (r != NULL) { - if (!BN_copy(r, b->Ai)) { - ret = 0; - } - } - if (!BN_mod_mul(n, n, b->A, b->mod, ctx)) { ret = 0; } @@ -256,31 +243,12 @@ int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx) { return ret; } -int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx) { - return BN_BLINDING_invert_ex(n, NULL, b, ctx); -} - -int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, - BN_CTX *ctx) { - int ret; - - if (r != NULL) { - ret = BN_mod_mul(n, n, r, b->mod, ctx); - } else { - if (b->Ai == NULL) { - OPENSSL_PUT_ERROR(RSA, RSA_R_BN_NOT_INITIALIZED); - return 0; - } - ret = BN_mod_mul(n, n, b->Ai, b->mod, ctx); +int BN_BLINDING_invert(BIGNUM *n, const BN_BLINDING *b, BN_CTX *ctx) { + if (b->Ai == NULL) { + OPENSSL_PUT_ERROR(RSA, RSA_R_BN_NOT_INITIALIZED); + return 0; } - - return ret; -} - -unsigned long BN_BLINDING_get_flags(const BN_BLINDING *b) { return b->flags; } - -void BN_BLINDING_set_flags(BN_BLINDING *b, unsigned long flags) { - b->flags = flags; + return BN_mod_mul(n, n, b->Ai, b->mod, ctx); } BN_BLINDING *BN_BLINDING_create_param( diff --git a/crypto/rsa/internal.h b/crypto/rsa/internal.h index 4e896e28..4d27344e 100644 --- a/crypto/rsa/internal.h +++ b/crypto/rsa/internal.h @@ -90,19 +90,11 @@ int rsa_default_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb); #define RSA_PKCS1_PADDING_SIZE 11 -/* BN_BLINDING flags */ -#define BN_BLINDING_NO_UPDATE 0x00000001 -#define BN_BLINDING_NO_RECREATE 0x00000002 - BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod); void BN_BLINDING_free(BN_BLINDING *b); int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx); int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); -int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); -int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *); -int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *); -unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); -void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); +int BN_BLINDING_invert(BIGNUM *n, const BN_BLINDING *b, BN_CTX *ctx); 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, diff --git a/crypto/rsa/rsa_impl.c b/crypto/rsa/rsa_impl.c index 41acf0d6..ba310739 100644 --- a/crypto/rsa/rsa_impl.c +++ b/crypto/rsa/rsa_impl.c @@ -548,7 +548,7 @@ int rsa_default_private_transform(RSA *rsa, uint8_t *out, const uint8_t *in, OPENSSL_PUT_ERROR(RSA, ERR_R_INTERNAL_ERROR); goto err; } - if (!BN_BLINDING_convert_ex(f, NULL, blinding, ctx)) { + if (!BN_BLINDING_convert(f, blinding, ctx)) { goto err; } } @@ -580,7 +580,7 @@ int rsa_default_private_transform(RSA *rsa, uint8_t *out, const uint8_t *in, } if (blinding) { - if (!BN_BLINDING_invert_ex(result, NULL, blinding, ctx)) { + if (!BN_BLINDING_invert(result, blinding, ctx)) { goto err; } } |