summaryrefslogtreecommitdiff
path: root/lib/libcrypto/rsa
diff options
context:
space:
mode:
authorBrent Cook <bcook@cvs.openbsd.org>2016-07-07 11:53:13 +0000
committerBrent Cook <bcook@cvs.openbsd.org>2016-07-07 11:53:13 +0000
commit6292826c2427c49fa679c9cf1d283e884666dfe1 (patch)
tree8c918ed99b88511d8169292fe8202bb56315bd64 /lib/libcrypto/rsa
parentec6c554d10c313c5eaf679d71da10aa8e352d057 (diff)
call BN_init on temporaries to avoid use-before-set warnings
ok beck@
Diffstat (limited to 'lib/libcrypto/rsa')
-rw-r--r--lib/libcrypto/rsa/rsa_crpt.c3
-rw-r--r--lib/libcrypto/rsa/rsa_eay.c11
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/libcrypto/rsa/rsa_crpt.c b/lib/libcrypto/rsa/rsa_crpt.c
index b50e4a4a6fc..ccb677c12b0 100644
--- a/lib/libcrypto/rsa/rsa_crpt.c
+++ b/lib/libcrypto/rsa/rsa_crpt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rsa_crpt.c,v 1.15 2016/06/30 02:02:06 bcook Exp $ */
+/* $OpenBSD: rsa_crpt.c,v 1.16 2016/07/07 11:53:12 bcook Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -192,6 +192,7 @@ RSA_setup_blinding(RSA *rsa, BN_CTX *in_ctx)
} else
e = rsa->e;
+ BN_init(&n);
BN_with_flags(&n, rsa->n, BN_FLG_CONSTTIME);
ret = BN_BLINDING_create_param(NULL, e, &n, ctx, rsa->meth->bn_mod_exp,
diff --git a/lib/libcrypto/rsa/rsa_eay.c b/lib/libcrypto/rsa/rsa_eay.c
index 6edfd7e5fdc..2facd1c6f6a 100644
--- a/lib/libcrypto/rsa/rsa_eay.c
+++ b/lib/libcrypto/rsa/rsa_eay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rsa_eay.c,v 1.41 2016/06/30 02:02:06 bcook Exp $ */
+/* $OpenBSD: rsa_eay.c,v 1.42 2016/07/07 11:53:12 bcook Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -432,6 +432,7 @@ RSA_eay_private_encrypt(int flen, const unsigned char *from, unsigned char *to,
} else {
BIGNUM d;
+ BN_init(&d);
BN_with_flags(&d, rsa->d, BN_FLG_CONSTTIME);
if (rsa->flags & RSA_FLAG_CACHE_PUBLIC)
@@ -556,6 +557,7 @@ RSA_eay_private_decrypt(int flen, const unsigned char *from, unsigned char *to,
} else {
BIGNUM d;
+ BN_init(&d);
BN_with_flags(&d, rsa->d, BN_FLG_CONSTTIME);
if (rsa->flags & RSA_FLAG_CACHE_PUBLIC)
@@ -742,6 +744,8 @@ RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
* Make sure BN_mod_inverse in Montgomery intialization uses the
* BN_FLG_CONSTTIME flag
*/
+ BN_init(&p);
+ BN_init(&q);
BN_with_flags(&p, rsa->p, BN_FLG_CONSTTIME);
BN_with_flags(&q, rsa->q, BN_FLG_CONSTTIME);
@@ -761,12 +765,14 @@ RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
goto err;
/* compute I mod q */
+ BN_init(&c);
BN_with_flags(&c, I, BN_FLG_CONSTTIME);
if (!BN_mod(r1, &c, rsa->q, ctx))
goto err;
/* compute r1^dmq1 mod q */
+ BN_init(&dmq1);
BN_with_flags(&dmq1, rsa->dmq1, BN_FLG_CONSTTIME);
if (!rsa->meth->bn_mod_exp(m1, r1, &dmq1, rsa->q, ctx,
@@ -780,6 +786,7 @@ RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
goto err;
/* compute r1^dmp1 mod p */
+ BN_init(&dmp1);
BN_with_flags(&dmp1, rsa->dmp1, BN_FLG_CONSTTIME);
if (!rsa->meth->bn_mod_exp(r0, r1, &dmp1, rsa->p, ctx,
@@ -801,6 +808,7 @@ RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
goto err;
/* Turn BN_FLG_CONSTTIME flag on before division operation */
+ BN_init(&pr1);
BN_with_flags(&pr1, r1, BN_FLG_CONSTTIME);
if (!BN_mod(r0, &pr1, rsa->p, ctx))
@@ -847,6 +855,7 @@ RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
*/
BIGNUM d;
+ BN_init(&d);
BN_with_flags(&d, rsa->d, BN_FLG_CONSTTIME);
if (!rsa->meth->bn_mod_exp(r0, I, &d, rsa->n, ctx,