summaryrefslogtreecommitdiff
path: root/deps/openssl/openssl/crypto/rand/md_rand.c
diff options
context:
space:
mode:
Diffstat (limited to 'deps/openssl/openssl/crypto/rand/md_rand.c')
-rw-r--r--deps/openssl/openssl/crypto/rand/md_rand.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/deps/openssl/openssl/crypto/rand/md_rand.c b/deps/openssl/openssl/crypto/rand/md_rand.c
index 1e3bcb9bc4..b2f04ff13e 100644
--- a/deps/openssl/openssl/crypto/rand/md_rand.c
+++ b/deps/openssl/openssl/crypto/rand/md_rand.c
@@ -109,8 +109,6 @@
*
*/
-#define OPENSSL_FIPSEVP
-
#ifdef MD_RAND_DEBUG
# ifndef NDEBUG
# define NDEBUG
@@ -123,10 +121,10 @@
#include "e_os.h"
-#include <openssl/crypto.h>
#include <openssl/rand.h>
#include "rand_lcl.h"
+#include <openssl/crypto.h>
#include <openssl/err.h>
#ifdef BN_DEBUG
@@ -159,14 +157,13 @@ const char RAND_version[]="RAND" OPENSSL_VERSION_PTEXT;
static void ssleay_rand_cleanup(void);
static void ssleay_rand_seed(const void *buf, int num);
static void ssleay_rand_add(const void *buf, int num, double add_entropy);
-static int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo);
-static int ssleay_rand_nopseudo_bytes(unsigned char *buf, int num);
+static int ssleay_rand_bytes(unsigned char *buf, int num);
static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num);
static int ssleay_rand_status(void);
RAND_METHOD rand_ssleay_meth={
ssleay_rand_seed,
- ssleay_rand_nopseudo_bytes,
+ ssleay_rand_bytes,
ssleay_rand_cleanup,
ssleay_rand_add,
ssleay_rand_pseudo_bytes,
@@ -331,7 +328,7 @@ static void ssleay_rand_seed(const void *buf, int num)
ssleay_rand_add(buf, num, (double)num);
}
-static int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo)
+static int ssleay_rand_bytes(unsigned char *buf, int num)
{
static volatile int stirred_pool = 0;
int i,j,k,st_num,st_idx;
@@ -520,9 +517,7 @@ static int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo)
EVP_MD_CTX_cleanup(&m);
if (ok)
return(1);
- else if (pseudo)
- return 0;
- else
+ else
{
RANDerr(RAND_F_SSLEAY_RAND_BYTES,RAND_R_PRNG_NOT_SEEDED);
ERR_add_error_data(1, "You need to read the OpenSSL FAQ, "
@@ -531,16 +526,22 @@ static int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo)
}
}
-static int ssleay_rand_nopseudo_bytes(unsigned char *buf, int num)
- {
- return ssleay_rand_bytes(buf, num, 0);
- }
-
/* pseudo-random bytes that are guaranteed to be unique but not
unpredictable */
static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num)
{
- return ssleay_rand_bytes(buf, num, 1);
+ int ret;
+ unsigned long err;
+
+ ret = RAND_bytes(buf, num);
+ if (ret == 0)
+ {
+ err = ERR_peek_error();
+ if (ERR_GET_LIB(err) == ERR_LIB_RAND &&
+ ERR_GET_REASON(err) == RAND_R_PRNG_NOT_SEEDED)
+ ERR_clear_error();
+ }
+ return (ret);
}
static int ssleay_rand_status(void)