fix WIN32 warnings
[openssl.git] / crypto / dsa / dsa_key.c
index fa4fb09..0c47ac4 100644 (file)
 #include <openssl/fips.h>
 #include <openssl/evp.h>
 
-static int fips_dsa_pairwise_fail = 0;
-
-void FIPS_corrupt_dsa_keygen(void)
-       {
-       fips_dsa_pairwise_fail = 1;
-       }
-
 static int fips_check_dsa(DSA *dsa)
        {
        EVP_PKEY pk;
@@ -85,7 +78,8 @@ static int fips_check_dsa(DSA *dsa)
        pk.type = EVP_PKEY_DSA;
        pk.pkey.dsa = dsa;
 
-       if (!fips_pkey_signature_test(&pk, tbs, -1, NULL, 0, NULL, 0, NULL))
+       if (!fips_pkey_signature_test(FIPS_TEST_PAIRWISE,
+                                       &pk, tbs, 0, NULL, 0, NULL, 0, NULL))
                {
                FIPSerr(FIPS_F_FIPS_CHECK_DSA,FIPS_R_PAIRWISE_TEST_FAILED);
                fips_set_selftest_fail();
@@ -112,11 +106,14 @@ static int dsa_builtin_keygen(DSA *dsa)
        BIGNUM *pub_key=NULL,*priv_key=NULL;
 
 #ifdef OPENSSL_FIPS
-       if (FIPS_mode() && (BN_num_bits(dsa->p) < OPENSSL_DSA_FIPS_MIN_MODULUS_BITS))
+       if (FIPS_module_mode() && !(dsa->flags & DSA_FLAG_NON_FIPS_ALLOW)
+               && (BN_num_bits(dsa->p) < OPENSSL_DSA_FIPS_MIN_MODULUS_BITS))
                {
                DSAerr(DSA_F_DSA_BUILTIN_KEYGEN, DSA_R_KEY_SIZE_TOO_SMALL);
                goto err;
                }
+       if (!fips_check_dsa_prng(dsa, 0, 0))
+               goto err;
 #endif
 
        if ((ctx=BN_CTX_new()) == NULL) goto err;
@@ -158,8 +155,6 @@ static int dsa_builtin_keygen(DSA *dsa)
        dsa->priv_key=priv_key;
        dsa->pub_key=pub_key;
 #ifdef OPENSSL_FIPS
-       if (fips_dsa_pairwise_fail)
-               BN_add_word(dsa->pub_key, 1);
        if(!fips_check_dsa(dsa))
                {
                dsa->pub_key = NULL;