提交 a28a5d9c 编写于 作者: B Bodo Möller

Use BN_with_flags() in a cleaner way.

上级 3f791ca8
...@@ -253,6 +253,8 @@ extern "C" { ...@@ -253,6 +253,8 @@ extern "C" {
#define BN_set_flags(b,n) ((b)->flags|=(n)) #define BN_set_flags(b,n) ((b)->flags|=(n))
#define BN_get_flags(b,n) ((b)->flags&(n)) #define BN_get_flags(b,n) ((b)->flags&(n))
/* get a clone of a BIGNUM with changed flags, for *temporary* use only
* (the two BIGNUMs cannot not be used in parallel!) */
#define BN_with_flags(dest,b,n) ((dest)->d=(b)->d, \ #define BN_with_flags(dest,b,n) ((dest)->d=(b)->d, \
(dest)->top=(b)->top, \ (dest)->top=(b)->top, \
(dest)->dmax=(b)->dmax, \ (dest)->dmax=(b)->dmax, \
......
...@@ -148,6 +148,7 @@ static int generate_key(DH *dh) ...@@ -148,6 +148,7 @@ static int generate_key(DH *dh)
if ((dh->flags & DH_FLAG_NO_EXP_CONSTTIME) == 0) if ((dh->flags & DH_FLAG_NO_EXP_CONSTTIME) == 0)
{ {
BN_init(&local_prk);
prk = &local_prk; prk = &local_prk;
BN_with_flags(prk, priv_key, BN_FLG_EXP_CONSTTIME); BN_with_flags(prk, priv_key, BN_FLG_EXP_CONSTTIME);
} }
......
...@@ -105,6 +105,7 @@ static int dsa_builtin_keygen(DSA *dsa) ...@@ -105,6 +105,7 @@ static int dsa_builtin_keygen(DSA *dsa)
if ((dsa->flags & DSA_FLAG_NO_EXP_CONSTTIME) == 0) if ((dsa->flags & DSA_FLAG_NO_EXP_CONSTTIME) == 0)
{ {
BN_init(&local_prk);
prk = &local_prk; prk = &local_prk;
BN_with_flags(prk, priv_key, BN_FLG_EXP_CONSTTIME); BN_with_flags(prk, priv_key, BN_FLG_EXP_CONSTTIME);
} }
......
...@@ -383,6 +383,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from, ...@@ -383,6 +383,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
if (!(rsa->flags & RSA_FLAG_NO_EXP_CONSTTIME)) if (!(rsa->flags & RSA_FLAG_NO_EXP_CONSTTIME))
{ {
BN_init(&local_d);
d = &local_d; d = &local_d;
BN_with_flags(d, rsa->d, BN_FLG_EXP_CONSTTIME); BN_with_flags(d, rsa->d, BN_FLG_EXP_CONSTTIME);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册