Use BN_with_flags() in a cleaner way.
authorBodo Möller <bodo@openssl.org>
Fri, 27 May 2005 15:38:53 +0000 (15:38 +0000)
committerBodo Möller <bodo@openssl.org>
Fri, 27 May 2005 15:38:53 +0000 (15:38 +0000)
crypto/bn/bn.h
crypto/dh/dh_key.c
crypto/dsa/dsa_key.c
crypto/rsa/rsa_eay.c

index 6d5273520747c3182eeee20fb8fc377ed7be96e0..9f4668a51da741eb390445d2cfacea1f95b7efbd 100644 (file)
@@ -253,6 +253,8 @@ extern "C" {
 #define BN_set_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, \
                                   (dest)->top=(b)->top, \
                                   (dest)->dmax=(b)->dmax, \
index e384286c73ffb3d942e48594bfdb67c7dcd404a7..39eefe387eab82b63a3e0a3c42097d4012771f44 100644 (file)
@@ -148,6 +148,7 @@ static int generate_key(DH *dh)
 
                if ((dh->flags & DH_FLAG_NO_EXP_CONSTTIME) == 0)
                        {
+                       BN_init(&local_prk);
                        prk = &local_prk;
                        BN_with_flags(prk, priv_key, BN_FLG_EXP_CONSTTIME);
                        }
index 5ba885e1e24ef3cc25c2700928279f38192bafe0..0423f2e00cd254c103293e7c67a57dbd6f2a80d0 100644 (file)
@@ -105,6 +105,7 @@ static int dsa_builtin_keygen(DSA *dsa)
 
                if ((dsa->flags & DSA_FLAG_NO_EXP_CONSTTIME) == 0)
                        {
+                       BN_init(&local_prk);
                        prk = &local_prk;
                        BN_with_flags(prk, priv_key, BN_FLG_EXP_CONSTTIME);
                        }
index 175ab8a789d8afd846a0cf5f3422073569a412fb..6954f36d5d431da70577c11f6c0f51761e811712 100644 (file)
@@ -383,6 +383,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
                
                if (!(rsa->flags & RSA_FLAG_NO_EXP_CONSTTIME))
                        {
+                       BN_init(&local_d);
                        d = &local_d;
                        BN_with_flags(d, rsa->d, BN_FLG_EXP_CONSTTIME);
                        }