X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=crypto%2Frand%2Fmd_rand.c;h=0ce390b5c015a61ec50ee52ba3dab20171db0904;hp=dbf13e686fe1525440228d5305130eae8cc9b97b;hb=023c8d0b0aec445b680ef5aea2bd2154adb59974;hpb=6b691a5c85ddc4e407e32781841fee5c029506cd diff --git a/crypto/rand/md_rand.c b/crypto/rand/md_rand.c index dbf13e686f..0ce390b5c0 100644 --- a/crypto/rand/md_rand.c +++ b/crypto/rand/md_rand.c @@ -57,23 +57,24 @@ */ #include -#include #include #include -#include "e_os.h" -#include "crypto.h" + +#include "openssl/e_os.h" + +#include #if !defined(USE_MD5_RAND) && !defined(USE_SHA1_RAND) && !defined(USE_MDC2_RAND) && !defined(USE_MD2_RAND) -#ifndef NO_MD5 -#define USE_MD5_RAND -#elif !defined(NO_SHA1) +#if !defined(NO_SHA) && !defined(NO_SHA1) #define USE_SHA1_RAND -#elif !defined(NO_MDC2) +#elif !defined(NO_MD5) +#define USE_MD5_RAND +#elif !defined(NO_MDC2) && !defined(NO_DES) #define USE_MDC2_RAND #elif !defined(NO_MD2) #define USE_MD2_RAND #else -We need a message digest of some type +#error No message digest algorithm available #endif #endif @@ -84,7 +85,7 @@ We need a message digest of some type */ #if defined(USE_MD5_RAND) -#include "md5.h" +#include #define MD_DIGEST_LENGTH MD5_DIGEST_LENGTH #define MD_CTX MD5_CTX #define MD_Init(a) MD5_Init(a) @@ -92,7 +93,7 @@ We need a message digest of some type #define MD_Final(a,b) MD5_Final(a,b) #define MD(a,b,c) MD5(a,b,c) #elif defined(USE_SHA1_RAND) -#include "sha.h" +#include #define MD_DIGEST_LENGTH SHA_DIGEST_LENGTH #define MD_CTX SHA_CTX #define MD_Init(a) SHA1_Init(a) @@ -100,7 +101,7 @@ We need a message digest of some type #define MD_Final(a,b) SHA1_Final(a,b) #define MD(a,b,c) SHA1(a,b,c) #elif defined(USE_MDC2_RAND) -#include "mdc2.h" +#include #define MD_DIGEST_LENGTH MDC2_DIGEST_LENGTH #define MD_CTX MDC2_CTX #define MD_Init(a) MDC2_Init(a) @@ -108,7 +109,7 @@ We need a message digest of some type #define MD_Final(a,b) MDC2_Final(a,b) #define MD(a,b,c) MDC2(a,b,c) #elif defined(USE_MD2_RAND) -#include "md2.h" +#include #define MD_DIGEST_LENGTH MD2_DIGEST_LENGTH #define MD_CTX MD2_CTX #define MD_Init(a) MD2_Init(a) @@ -117,7 +118,7 @@ We need a message digest of some type #define MD(a,b,c) MD2(a,b,c) #endif -#include "rand.h" +#include /* #define NORAND 1 */ /* #define PREDICT 1 */ @@ -241,7 +242,6 @@ static void ssleay_rand_bytes(unsigned char *buf, int num) if (init) { - init=0; CRYPTO_w_unlock(CRYPTO_LOCK_RAND); /* put in some default random data, we need more than * just this */ @@ -255,7 +255,7 @@ static void ssleay_rand_bytes(unsigned char *buf, int num) l=time(NULL); RAND_seed(&l,sizeof(l)); -/* #ifdef DEVRANDOM */ +#ifdef DEVRANDOM /* * Use a random entropy pool device. * Linux 1.3.x and FreeBSD-Current has @@ -275,12 +275,13 @@ static void ssleay_rand_bytes(unsigned char *buf, int num) RAND_seed(tmpbuf,32); memset(tmpbuf,0,32); } -/* #endif */ +#endif #ifdef PURIFY memset(state,0,STATE_SIZE); memset(md,0,MD_DIGEST_LENGTH); #endif CRYPTO_w_lock(CRYPTO_LOCK_RAND); + init=0; } st_idx=state_index; @@ -330,7 +331,7 @@ static void ssleay_rand_bytes(unsigned char *buf, int num) #ifdef WINDOWS #include -#include +#include /***************************************************************************** * Initialisation function for the SSL random generator. Takes the contents