Set flag BN_FLG_CONSTTIME earlier
authorCesar Pereida <cesar.pereida@aalto.fi>
Tue, 7 Jun 2016 13:02:01 +0000 (16:02 +0300)
committerMatt Caswell <matt@openssl.org>
Tue, 7 Jun 2016 14:26:57 +0000 (15:26 +0100)
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
crypto/dsa/dsa_ossl.c

index 81c5239..9c97ef9 100644 (file)
@@ -167,6 +167,8 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in,
             goto err;
     } while (BN_is_zero(k));
 
+    BN_set_flags(k, BN_FLG_CONSTTIME);
+
     if (dsa->flags & DSA_FLAG_CACHE_MONT_P) {
         if (!BN_MONT_CTX_set_locked(&dsa->method_mont_p,
                                     dsa->lock, dsa->p, ctx))
@@ -189,8 +191,6 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in,
             goto err;
     }
 
-    BN_set_flags(k, BN_FLG_CONSTTIME);
-
     if ((dsa)->meth->bn_mod_exp != NULL) {
             if (!dsa->meth->bn_mod_exp(dsa, r, dsa->g, k, dsa->p, ctx,
                                        dsa->method_mont_p))
@@ -200,7 +200,6 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in,
                 goto err;
     }
 
-
     if (!BN_mod(r, r, dsa->q, ctx))
         goto err;