summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2014-07-31 21:22:23 +0100
committerDr. Stephen Henson <steve@openssl.org>2014-08-01 18:42:40 +0100
commita9f4ebd75343f34ef314965efe0b121f693a21e6 (patch)
tree68dd79a79f89366e6cd326bab8d7bdd5c0fdd413
parent604c9948a8e0f371cffa1906bfbd30a14dadaf78 (diff)
Fix error discrepancy.
We can't rename ssleay_rand_bytes to md_rand_bytes_lock as this will cause an error code discrepancy. Instead keep ssleay_rand_bytes and add an extra parameter: since ssleay_rand_bytes is not part of the public API this wont cause any binary compatibility issues. Reviewed-by: Kurt Roeckx <kurt@openssl.org > (cherry picked from commit 8068a675a7d1a657c54546f24e673e59e6707f03)
-rw-r--r--crypto/rand/md_rand.c12
-rw-r--r--crypto/rand/rand_lcl.h2
-rw-r--r--crypto/rand/rand_lib.c2
3 files changed, 5 insertions, 11 deletions
diff --git a/crypto/rand/md_rand.c b/crypto/rand/md_rand.c
index 5dd0a37d65..888b4eb8dd 100644
--- a/crypto/rand/md_rand.c
+++ b/crypto/rand/md_rand.c
@@ -159,7 +159,6 @@ 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_pseudo_bytes(unsigned char *buf, int num);
static int ssleay_rand_status(void);
@@ -334,12 +333,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)
- {
- return md_rand_bytes_lock(buf, num, pseudo, 1);
- }
-
-int md_rand_bytes_lock(unsigned char *buf, int num, int pseudo, int lock)
+int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo, int lock)
{
static volatile int stirred_pool = 0;
int i,j,k,st_num,st_idx;
@@ -544,14 +538,14 @@ int md_rand_bytes_lock(unsigned char *buf, int num, int pseudo, int lock)
static int ssleay_rand_nopseudo_bytes(unsigned char *buf, int num)
{
- return ssleay_rand_bytes(buf, num, 0);
+ return ssleay_rand_bytes(buf, num, 0, 1);
}
/* 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);
+ return ssleay_rand_bytes(buf, num, 1, 1);
}
static int ssleay_rand_status(void)
diff --git a/crypto/rand/rand_lcl.h b/crypto/rand/rand_lcl.h
index 725cdb31c2..0fabf8dc5d 100644
--- a/crypto/rand/rand_lcl.h
+++ b/crypto/rand/rand_lcl.h
@@ -154,6 +154,6 @@
#define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_md2(), NULL)
#endif
-int md_rand_bytes_lock(unsigned char *buf, int num, int pseudo, int lock);
+int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo, int lock);
#endif
diff --git a/crypto/rand/rand_lib.c b/crypto/rand/rand_lib.c
index 54f1d35c6c..239a1cde81 100644
--- a/crypto/rand/rand_lib.c
+++ b/crypto/rand/rand_lib.c
@@ -200,7 +200,7 @@ static size_t drbg_get_entropy(DRBG_CTX *ctx, unsigned char **pout,
*pout = OPENSSL_malloc(min_len);
if (!*pout)
return 0;
- if (md_rand_bytes_lock(*pout, min_len, 0, 0) <= 0)
+ if (ssleay_rand_bytes(*pout, min_len, 0, 0) <= 0)
{
OPENSSL_free(*pout);
*pout = NULL;