mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 16:18:48 -05:00
Merge branch 'master' of github.com:bagder/curl
Merge for resync
This commit is contained in:
commit
695931cf8e
66
lib/sslgen.c
66
lib/sslgen.c
@ -187,45 +187,43 @@ unsigned int Curl_rand(struct SessionHandle *data)
|
|||||||
{
|
{
|
||||||
unsigned int r;
|
unsigned int r;
|
||||||
static unsigned int randseed;
|
static unsigned int randseed;
|
||||||
static bool seeded;
|
static bool seeded = FALSE;
|
||||||
|
|
||||||
#ifdef have_curlssl_random
|
#ifndef have_curlssl_random
|
||||||
if(!data) {
|
(void)data;
|
||||||
#endif
|
#else
|
||||||
|
if(data) {
|
||||||
if(!seeded) {
|
|
||||||
|
|
||||||
#ifdef RANDOM_FILE
|
|
||||||
/* if there's a random file to read a seed from, use it */
|
|
||||||
int fd = open(RANDOM_FILE, O_RDONLY);
|
|
||||||
seeded = TRUE;
|
|
||||||
if(fd > -1) {
|
|
||||||
/* read random data into the randseed variable */
|
|
||||||
read(fd, &randseed, sizeof(randseed));
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif /* RANDOM_FILE */
|
|
||||||
{
|
|
||||||
struct timeval now = curlx_tvnow();
|
|
||||||
randseed += (unsigned int) now.tv_usec + (unsigned int)now.tv_sec;
|
|
||||||
randseed = randseed * 1103515245 + 12345;
|
|
||||||
randseed = randseed * 1103515245 + 12345;
|
|
||||||
randseed = randseed * 1103515245 + 12345;
|
|
||||||
seeded = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Return an unsigned 32-bit pseudo-random number. */
|
|
||||||
r = randseed = randseed * 1103515245 + 12345;
|
|
||||||
return (r << 16) | ((r >> 16) & 0xFFFF);
|
|
||||||
|
|
||||||
#ifdef have_curlssl_random
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Curl_ssl_random(data, (unsigned char *)&r, sizeof(r));
|
Curl_ssl_random(data, (unsigned char *)&r, sizeof(r));
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef RANDOM_FILE
|
||||||
|
if(!seeded) {
|
||||||
|
/* if there's a random file to read a seed from, use it */
|
||||||
|
int fd = open(RANDOM_FILE, O_RDONLY);
|
||||||
|
if(fd > -1) {
|
||||||
|
/* read random data into the randseed variable */
|
||||||
|
ssize_t nread = read(fd, &randseed, sizeof(randseed));
|
||||||
|
if(nread == sizeof(randseed))
|
||||||
|
seeded = TRUE;
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(!seeded) {
|
||||||
|
struct timeval now = curlx_tvnow();
|
||||||
|
randseed += (unsigned int)now.tv_usec + (unsigned int)now.tv_sec;
|
||||||
|
randseed = randseed * 1103515245 + 12345;
|
||||||
|
randseed = randseed * 1103515245 + 12345;
|
||||||
|
randseed = randseed * 1103515245 + 12345;
|
||||||
|
seeded = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return an unsigned 32-bit pseudo-random number. */
|
||||||
|
r = randseed = randseed * 1103515245 + 12345;
|
||||||
|
return (r << 16) | ((r >> 16) & 0xFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_SSL
|
#ifdef USE_SSL
|
||||||
|
Loading…
Reference in New Issue
Block a user