Disable Dual EC DRBG.
authorDr. Stephen Henson <steve@openssl.org>
Mon, 16 Sep 2013 04:23:44 +0000 (05:23 +0100)
committerDr. Stephen Henson <steve@openssl.org>
Sun, 22 Sep 2013 17:24:12 +0000 (18:24 +0100)
Return an error if an attempt is made to enable the Dual EC DRBG: it
is not used by default.

crypto/rand/rand.h
crypto/rand/rand_err.c
crypto/rand/rand_lib.c

index dc8fcf94c5aa87bbb314b72055d108945dc2a90a..bb5520e80ac161cc498941b73dea9e3665301d10 100644 (file)
@@ -138,6 +138,7 @@ void ERR_load_RAND_strings(void);
 #define RAND_F_SSLEAY_RAND_BYTES                        100
 
 /* Reason codes. */
+#define RAND_R_DUAL_EC_DRBG_DISABLED                    104
 #define RAND_R_ERROR_INITIALISING_DRBG                  102
 #define RAND_R_ERROR_INSTANTIATING_DRBG                         103
 #define RAND_R_NO_FIPS_RANDOM_METHOD_SET                101
index b8586c8f4a9c3832616faf64812f7e8947bc67d5..c4c80fc8ccad4dc0a90de349301519f15152a5bd 100644 (file)
@@ -78,6 +78,7 @@ static ERR_STRING_DATA RAND_str_functs[]=
 
 static ERR_STRING_DATA RAND_str_reasons[]=
        {
+{ERR_REASON(RAND_R_DUAL_EC_DRBG_DISABLED),"dual ec drbg disabled"},
 {ERR_REASON(RAND_R_ERROR_INITIALISING_DRBG),"error initialising drbg"},
 {ERR_REASON(RAND_R_ERROR_INSTANTIATING_DRBG),"error instantiating drbg"},
 {ERR_REASON(RAND_R_NO_FIPS_RANDOM_METHOD_SET),"no fips random method set"},
index 476a0cd187ee7629526042e5de5728e6277a4b7c..5ac0e14caf00bd36539b5180985117bd2f94b8fd 100644 (file)
@@ -269,6 +269,14 @@ int RAND_init_fips(void)
        DRBG_CTX *dctx;
        size_t plen;
        unsigned char pers[32], *p;
+#ifndef OPENSSL_ALLOW_DUAL_EC_DRBG
+       if (fips_drbg_type >> 16)
+               {
+               RANDerr(RAND_F_RAND_INIT_FIPS, RAND_R_DUAL_EC_DRBG_DISABLED);
+               return 0;
+               }
+#endif
+               
        dctx = FIPS_get_default_drbg();
         if (FIPS_drbg_init(dctx, fips_drbg_type, fips_drbg_flags) <= 0)
                {