mirror of
https://github.com/curl/curl.git
synced 2026-08-26 10:33:33 +03:00
lib: remove use of RANDOM_FILE
It could previously be set with configure/cmake and used in rare cases for reading randomness: with ancient mbedTLS or rustls without arc4random. We now get randomness in this order: 1. The TLS library's way to provide random 2. On Windows: Curl_win32_random 3. if arc4random exists, use that 4. weak non-crytographically strong pseudo-random Closes #14749
This commit is contained in:
parent
00ef607326
commit
269fdd4c6e
8 changed files with 0 additions and 62 deletions
|
|
@ -65,9 +65,6 @@
|
|||
/* Define this to 'int' if ssize_t is not an available typedefed type */
|
||||
#undef ssize_t
|
||||
|
||||
/* Define this as a suitable file to read random data from */
|
||||
#undef RANDOM_FILE
|
||||
|
||||
/* Define to 1 if you have the alarm function. */
|
||||
#define HAVE_ALARM 1
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@
|
|||
#define PACKAGE_STRING "curl -"
|
||||
#define PACKAGE_TARNAME "curl"
|
||||
#define PACKAGE_VERSION "-"
|
||||
#define RANDOM_FILE "/dev/random"
|
||||
#define VERSION "0.0.0" /* TODO */
|
||||
|
||||
#define STDC_HEADERS 1
|
||||
|
|
|
|||
|
|
@ -63,9 +63,6 @@
|
|||
/* Define this to 'int' if ssize_t is not an available typedefed type */
|
||||
#undef ssize_t
|
||||
|
||||
/* Define this as a suitable file to read random data from */
|
||||
#undef RANDOM_FILE
|
||||
|
||||
/* Define if you have the alarm function. */
|
||||
#define HAVE_ALARM
|
||||
|
||||
|
|
|
|||
|
|
@ -638,9 +638,6 @@
|
|||
/* Define to the version of this package. */
|
||||
#cmakedefine PACKAGE_VERSION ${PACKAGE_VERSION}
|
||||
|
||||
/* a suitable file to read random data from */
|
||||
#cmakedefine RANDOM_FILE "${RANDOM_FILE}"
|
||||
|
||||
/*
|
||||
Note: SIZEOF_* variables are fetched with CMake through check_type_size().
|
||||
As per CMake documentation on CheckTypeSize, C preprocessor code is
|
||||
|
|
|
|||
14
lib/rand.c
14
lib/rand.c
|
|
@ -154,20 +154,6 @@ static CURLcode randit(struct Curl_easy *data, unsigned int *rnd,
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(RANDOM_FILE) && !defined(_WIN32)
|
||||
if(!seeded) {
|
||||
/* if there is 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 curltime now = Curl_now();
|
||||
infof(data, "WARNING: using weak random seed");
|
||||
|
|
|
|||
|
|
@ -998,12 +998,6 @@ static CURLcode ossl_seed(struct Curl_easy *data)
|
|||
return CURLE_SSL_CONNECT_ERROR;
|
||||
#else
|
||||
|
||||
#ifdef RANDOM_FILE
|
||||
RAND_load_file(RANDOM_FILE, RAND_LOAD_LENGTH);
|
||||
if(rand_enough())
|
||||
return CURLE_OK;
|
||||
#endif
|
||||
|
||||
/* fallback to a custom seeding of the PRNG using a hash based on a current
|
||||
time */
|
||||
do {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue