Remove s = s * P deferral.
authorDr. Stephen Henson <steve@openssl.org>
Thu, 29 Sep 2011 18:22:37 +0000 (18:22 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Thu, 29 Sep 2011 18:22:37 +0000 (18:22 +0000)
fips/rand/fips_drbg_ec.c
fips/rand/fips_rand_lcl.h

index c4d7612d6c43b6467c2919e9760eb5698d5fb0eb..6be6534ce75daae1e65b5fc10e97e4b3c6c44073 100644 (file)
@@ -241,13 +241,6 @@ static int drbg_ec_reseed(DRBG_CTX *dctx,
                                const unsigned char *adin, size_t adin_len)
        {
        DRBG_EC_CTX *ectx = &dctx->d.ec;
                                const unsigned char *adin, size_t adin_len)
        {
        DRBG_EC_CTX *ectx = &dctx->d.ec;
-       /* Check if we have a deferred s = s * P */
-       if (ectx->sp_defer)
-               {
-               if (!drbg_ec_mul(ectx, ectx->s, ectx->s, 0))
-                       return 0;
-               ectx->sp_defer = 0;
-               }
        /* Convert s value to a binary buffer. Save it to tbuf as we are
         * about to overwrite it.
         */
        /* Convert s value to a binary buffer. Save it to tbuf as we are
         * about to overwrite it.
         */
@@ -278,13 +271,6 @@ static int drbg_ec_generate(DRBG_CTX *dctx,
                        dctx->status = DRBG_STATUS_RESEED;
                return 1;
                }
                        dctx->status = DRBG_STATUS_RESEED;
                return 1;
                }
-       /* Check if we have a deferred s = s * P */
-       if (ectx->sp_defer)
-               {
-               if (!drbg_ec_mul(ectx, s, s, 0))
-                       goto err;
-               ectx->sp_defer = 0;
-               }
 
        BN_CTX_start(ectx->bctx);
        r = BN_CTX_get(ectx->bctx);
 
        BN_CTX_start(ectx->bctx);
        r = BN_CTX_get(ectx->bctx);
@@ -371,8 +357,8 @@ static int drbg_ec_generate(DRBG_CTX *dctx,
                hexprint(stderr, out, dctx->blocklength);
 #endif
                }
                hexprint(stderr, out, dctx->blocklength);
 #endif
                }
-       /* Defer s = s * P until we need it */
-       ectx->sp_defer = 1;
+       if (!drbg_ec_mul(ectx, ectx->s, ectx->s, 0))
+               return 0;
 #ifdef EC_DRBG_TRACE
        bnprint(stderr, "s after generate is: ", s);
 #endif
 #ifdef EC_DRBG_TRACE
        bnprint(stderr, "s after generate is: ", s);
 #endif
@@ -534,8 +520,6 @@ int fips_drbg_ec_init(DRBG_CTX *dctx)
        ectx->Q = EC_POINT_new(ectx->curve);
        ectx->ptmp = EC_POINT_new(ectx->curve);
 
        ectx->Q = EC_POINT_new(ectx->curve);
        ectx->ptmp = EC_POINT_new(ectx->curve);
 
-       ectx->sp_defer = 0;
-
        x = BN_CTX_get(ectx->bctx);
        y = BN_CTX_get(ectx->bctx);
 
        x = BN_CTX_get(ectx->bctx);
        y = BN_CTX_get(ectx->bctx);
 
index fc649c003b5235bdb46f84bf8461a597e3397c09..e03537bd5f25055694e05e9586d4e89efbae0f33 100644 (file)
@@ -116,8 +116,6 @@ struct drbg_ec_ctx_st
        EVP_MD_CTX mctx;
        /* Temporary value storage: should always exceed max digest length */
        unsigned char vtmp[EC_PRNG_MAX_SEEDLEN];
        EVP_MD_CTX mctx;
        /* Temporary value storage: should always exceed max digest length */
        unsigned char vtmp[EC_PRNG_MAX_SEEDLEN];
-       /* Flag to indicate s = s * P has been deferred */
-       int sp_defer;
        /* Temp BN context */
        BN_CTX *bctx;
        };
        /* Temp BN context */
        BN_CTX *bctx;
        };