Switch for turning on the predictable "random" number generator.
This commit is contained in:
parent
c9e1fe33be
commit
e64dceab74
@ -130,6 +130,10 @@
|
|||||||
|
|
||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
|
|
||||||
|
#ifdef BN_DEBUG
|
||||||
|
# define PREDICT
|
||||||
|
#endif
|
||||||
|
|
||||||
/* #define NORAND 1 */
|
/* #define NORAND 1 */
|
||||||
/* #define PREDICT 1 */
|
/* #define PREDICT 1 */
|
||||||
|
|
||||||
@ -141,6 +145,10 @@ static long md_count[2]={0,0};
|
|||||||
static double entropy=0;
|
static double entropy=0;
|
||||||
static int initialized=0;
|
static int initialized=0;
|
||||||
|
|
||||||
|
#ifdef PREDICT
|
||||||
|
int rand_predictable=0;
|
||||||
|
#endif
|
||||||
|
|
||||||
const char *RAND_version="RAND" OPENSSL_VERSION_PTEXT;
|
const char *RAND_version="RAND" OPENSSL_VERSION_PTEXT;
|
||||||
|
|
||||||
static void ssleay_rand_cleanup(void);
|
static void ssleay_rand_cleanup(void);
|
||||||
@ -306,6 +314,10 @@ static void ssleay_rand_initialize(void)
|
|||||||
FILE *fh;
|
FILE *fh;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef NORAND
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
|
CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
|
||||||
/* put in some default random data, we need more than just this */
|
/* put in some default random data, we need more than just this */
|
||||||
#ifndef GETPID_IS_MEANINGLESS
|
#ifndef GETPID_IS_MEANINGLESS
|
||||||
@ -354,13 +366,14 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PREDICT
|
#ifdef PREDICT
|
||||||
{
|
if (rand_predictable)
|
||||||
static unsigned char val=0;
|
{
|
||||||
|
static unsigned char val=0;
|
||||||
|
|
||||||
for (i=0; i<num; i++)
|
for (i=0; i<num; i++)
|
||||||
buf[i]=val++;
|
buf[i]=val++;
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -97,7 +97,7 @@ int RAND_egd(const char *path)
|
|||||||
buf[1] = 255;
|
buf[1] = 255;
|
||||||
write(fd, buf, 2);
|
write(fd, buf, 2);
|
||||||
if (read(fd, buf, 1) != 1) goto err;
|
if (read(fd, buf, 1) != 1) goto err;
|
||||||
if (buf[0] == 0) goto err;
|
if (buf[0] == 0) goto err;
|
||||||
num = read(fd, buf, 255);
|
num = read(fd, buf, 255);
|
||||||
if (num < 1) goto err;
|
if (num < 1) goto err;
|
||||||
RAND_seed(buf, num);
|
RAND_seed(buf, num);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user