Set rand method in FIPS_mode_set() not in rand library.
authorDr. Stephen Henson <steve@openssl.org>
Mon, 13 Jun 2011 21:18:00 +0000 (21:18 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Mon, 13 Jun 2011 21:18:00 +0000 (21:18 +0000)
crypto/o_fips.c
crypto/rand/rand_lib.c

index a57a02b..9474a0d 100644 (file)
@@ -58,6 +58,8 @@
 #include "cryptlib.h"
 #ifdef OPENSSL_FIPS
 #include <openssl/fips.h>
+#include <openssl/fips_rand.h>
+#include <openssl/rand.h>
 #endif
 
 int FIPS_mode(void)
@@ -71,8 +73,15 @@ int FIPS_mode(void)
 
 int FIPS_mode_set(int r)
        {
+       OPENSSL_init();
 #ifdef OPENSSL_FIPS
-       return FIPS_module_mode_set(r);
+       if (!FIPS_module_mode_set(r))
+               return 0;
+       if (r)
+               RAND_set_rand_method(FIPS_rand_get_method());
+       else
+               RAND_set_rand_method(NULL);
+       return 1;
 #else
        if (r == 0)
                return 1;
index 187fe1e..9f26683 100644 (file)
@@ -111,18 +111,6 @@ const RAND_METHOD *RAND_get_rand_method(void)
                if(e)
                        funct_ref = e;
                else
-#endif
-#ifdef OPENSSL_FIPS
-               if (FIPS_mode())
-                       {
-                       default_RAND_meth = FIPS_rand_get_method();
-                       if (default_RAND_meth == NULL)
-                               {
-                               RANDerr(RAND_F_RAND_GET_RAND_METHOD,
-                                       RAND_R_NO_FIPS_RANDOM_METHOD_SET);
-                               }
-                       }
-               else
 #endif
                        default_RAND_meth = RAND_SSLeay();
                }