From a9f4ebd75343f34ef314965efe0b121f693a21e6 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Thu, 31 Jul 2014 21:22:23 +0100 Subject: [PATCH] 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 (cherry picked from commit 8068a675a7d1a657c54546f24e673e59e6707f03) --- crypto/rand/md_rand.c | 12 +++--------- crypto/rand/rand_lcl.h | 2 +- crypto/rand/rand_lib.c | 2 +- 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; -- 2.34.1