diff options
Diffstat (limited to 'src/lib/libcrypto/rand/md_rand.c')
-rw-r--r-- | src/lib/libcrypto/rand/md_rand.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/lib/libcrypto/rand/md_rand.c b/src/lib/libcrypto/rand/md_rand.c index fcdd3f2a84..b2f04ff13e 100644 --- a/src/lib/libcrypto/rand/md_rand.c +++ b/src/lib/libcrypto/rand/md_rand.c | |||
@@ -109,8 +109,6 @@ | |||
109 | * | 109 | * |
110 | */ | 110 | */ |
111 | 111 | ||
112 | #define OPENSSL_FIPSEVP | ||
113 | |||
114 | #ifdef MD_RAND_DEBUG | 112 | #ifdef MD_RAND_DEBUG |
115 | # ifndef NDEBUG | 113 | # ifndef NDEBUG |
116 | # define NDEBUG | 114 | # define NDEBUG |
@@ -159,14 +157,13 @@ const char RAND_version[]="RAND" OPENSSL_VERSION_PTEXT; | |||
159 | static void ssleay_rand_cleanup(void); | 157 | static void ssleay_rand_cleanup(void); |
160 | static void ssleay_rand_seed(const void *buf, int num); | 158 | static void ssleay_rand_seed(const void *buf, int num); |
161 | static void ssleay_rand_add(const void *buf, int num, double add_entropy); | 159 | static void ssleay_rand_add(const void *buf, int num, double add_entropy); |
162 | static int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo); | 160 | static int ssleay_rand_bytes(unsigned char *buf, int num); |
163 | static int ssleay_rand_nopseudo_bytes(unsigned char *buf, int num); | ||
164 | static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num); | 161 | static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num); |
165 | static int ssleay_rand_status(void); | 162 | static int ssleay_rand_status(void); |
166 | 163 | ||
167 | RAND_METHOD rand_ssleay_meth={ | 164 | RAND_METHOD rand_ssleay_meth={ |
168 | ssleay_rand_seed, | 165 | ssleay_rand_seed, |
169 | ssleay_rand_nopseudo_bytes, | 166 | ssleay_rand_bytes, |
170 | ssleay_rand_cleanup, | 167 | ssleay_rand_cleanup, |
171 | ssleay_rand_add, | 168 | ssleay_rand_add, |
172 | ssleay_rand_pseudo_bytes, | 169 | ssleay_rand_pseudo_bytes, |
@@ -331,7 +328,7 @@ static void ssleay_rand_seed(const void *buf, int num) | |||
331 | ssleay_rand_add(buf, num, (double)num); | 328 | ssleay_rand_add(buf, num, (double)num); |
332 | } | 329 | } |
333 | 330 | ||
334 | static int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo) | 331 | static int ssleay_rand_bytes(unsigned char *buf, int num) |
335 | { | 332 | { |
336 | static volatile int stirred_pool = 0; | 333 | static volatile int stirred_pool = 0; |
337 | int i,j,k,st_num,st_idx; | 334 | int i,j,k,st_num,st_idx; |
@@ -520,9 +517,7 @@ static int ssleay_rand_bytes(unsigned char *buf, int num, int pseudo) | |||
520 | EVP_MD_CTX_cleanup(&m); | 517 | EVP_MD_CTX_cleanup(&m); |
521 | if (ok) | 518 | if (ok) |
522 | return(1); | 519 | return(1); |
523 | else if (pseudo) | 520 | else |
524 | return 0; | ||
525 | else | ||
526 | { | 521 | { |
527 | RANDerr(RAND_F_SSLEAY_RAND_BYTES,RAND_R_PRNG_NOT_SEEDED); | 522 | RANDerr(RAND_F_SSLEAY_RAND_BYTES,RAND_R_PRNG_NOT_SEEDED); |
528 | ERR_add_error_data(1, "You need to read the OpenSSL FAQ, " | 523 | 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) | |||
531 | } | 526 | } |
532 | } | 527 | } |
533 | 528 | ||
534 | static int ssleay_rand_nopseudo_bytes(unsigned char *buf, int num) | ||
535 | { | ||
536 | return ssleay_rand_bytes(buf, num, 0); | ||
537 | } | ||
538 | |||
539 | /* pseudo-random bytes that are guaranteed to be unique but not | 529 | /* pseudo-random bytes that are guaranteed to be unique but not |
540 | unpredictable */ | 530 | unpredictable */ |
541 | static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num) | 531 | static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num) |
542 | { | 532 | { |
543 | return ssleay_rand_bytes(buf, num, 1); | 533 | int ret; |
534 | unsigned long err; | ||
535 | |||
536 | ret = RAND_bytes(buf, num); | ||
537 | if (ret == 0) | ||
538 | { | ||
539 | err = ERR_peek_error(); | ||
540 | if (ERR_GET_LIB(err) == ERR_LIB_RAND && | ||
541 | ERR_GET_REASON(err) == RAND_R_PRNG_NOT_SEEDED) | ||
542 | ERR_clear_error(); | ||
543 | } | ||
544 | return (ret); | ||
544 | } | 545 | } |
545 | 546 | ||
546 | static int ssleay_rand_status(void) | 547 | static int ssleay_rand_status(void) |