make post failure simulation reversible in all cases
authorDr. Stephen Henson <steve@openssl.org>
Sat, 5 Nov 2011 18:14:42 +0000 (18:14 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Sat, 5 Nov 2011 18:14:42 +0000 (18:14 +0000)
fips/fips.h
fips/fips_test_suite.c
fips/rand/fips_drbg_lib.c
fips/rand/fips_rand.c
fips/rand/fips_rand_selftest.c

index 8833dd2e9ec7611231e87b23c0d8d759eb6095ea..b6263575c3cc37ad021f78370de76b42b16004be 100644 (file)
@@ -97,9 +97,8 @@ int FIPS_selftest_rsa(void);
 int FIPS_selftest_dsa(void);
 int FIPS_selftest_ecdsa(void);
 int FIPS_selftest_ecdh(void);
-void FIPS_corrupt_drbg(void);
-void FIPS_x931_stick(void);
-void FIPS_drbg_stick(void);
+void FIPS_x931_stick(int onoff);
+void FIPS_drbg_stick(int onoff);
 int FIPS_selftest_x931(void);
 int FIPS_selftest_hmac(void);
 int FIPS_selftest_drbg(void);
index ee706d8a9689e4fb6df124ddf61769a5e5568a4a..57a1b8a6a4830476086b388983aaa6b605796b51 100644 (file)
@@ -1104,9 +1104,9 @@ int main(int argc, char **argv)
     if (!FIPS_module_mode())
        return 1;
     if (do_drbg_stick)
-            FIPS_drbg_stick();
+            FIPS_drbg_stick(1);
     if (do_rng_stick)
-            FIPS_x931_stick();
+            FIPS_x931_stick(1);
 
     /* AES encryption/decryption
     */
index 1596977fd54d77b4967a5203d1139dc8d33e808f..e0e1d750916b8cf5badcb625653799a3a56a83c4 100644 (file)
@@ -544,9 +544,9 @@ void FIPS_drbg_set_reseed_interval(DRBG_CTX *dctx, int interval)
 
 static int drbg_stick = 0;
 
-void FIPS_drbg_stick(void)
+void FIPS_drbg_stick(int onoff)
        {
-       drbg_stick = 1;
+       drbg_stick = onoff;
        }
 
 /* Continuous DRBG utility function */
index cb9184e1f7a2bf9575262c6fbd8844ef99241275..f80c005758a04b63fa8168297a9c0538e36a0310 100644 (file)
@@ -114,9 +114,9 @@ static FIPS_PRNG_CTX sctx;
 
 static int fips_prng_fail = 0;
 
-void FIPS_x931_stick(void)
+void FIPS_x931_stick(int onoff)
        {
-       fips_prng_fail = 1;
+       fips_prng_fail = onoff;
        }
 
 static void fips_rand_prng_reset(FIPS_PRNG_CTX *ctx)
index bafce719cade2a9b74a7abc429cee3b2520b425e..ec949cbdbbeecdf3de611a3da3259e585b88a5e6 100644 (file)
@@ -129,15 +129,16 @@ static AES_PRNG_TV aes_256_tv =
 static int do_x931_test(unsigned char *key, int keylen,
                        AES_PRNG_TV *tv)
        {
-       unsigned char R[16];
+       unsigned char R[16], V[16];
        int rv = 1;
+       memcpy(V, tv->V, sizeof(V));
        if (!FIPS_x931_set_key(key, keylen))
                return 0;
        if (!fips_post_started(FIPS_TEST_X931, keylen, NULL))
                return 1;
        if (!fips_post_corrupt(FIPS_TEST_X931, keylen, NULL))
-               tv->V[0]++;
-       FIPS_x931_seed(tv->V, 16);
+               V[0]++;
+       FIPS_x931_seed(V, 16);
        FIPS_x931_set_dt(tv->DT);
        FIPS_x931_bytes(R, 16);
        if (memcmp(R, tv->R, 16))