mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
Lower log-level in different error conditions in entropy selection.
This patch lowers the log-level from warning to info in the cases where we are going to attempt another method as entropy source to hopefully make the user feel less concerned. See: https://bugs.torproject.org/25120
This commit is contained in:
parent
a2990081d5
commit
14c47a0b5c
@ -1891,6 +1891,12 @@ crypto_strongest_rand_syscall(uint8_t *out, size_t out_len)
|
||||
{
|
||||
tor_assert(out_len <= MAX_STRONGEST_RAND_SIZE);
|
||||
|
||||
/* We only log at notice-level here because in the case that this function
|
||||
* fails the crypto_strongest_rand_raw() caller will log with a warning-level
|
||||
* message and let crypto_strongest_rand() error out and finally terminating
|
||||
* Tor with an assertion error.
|
||||
*/
|
||||
|
||||
#ifdef TOR_UNIT_TESTS
|
||||
if (break_strongest_rng_syscall)
|
||||
return -1;
|
||||
@ -1903,13 +1909,13 @@ crypto_strongest_rand_syscall(uint8_t *out, size_t out_len)
|
||||
if (!provider_set) {
|
||||
if (!CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL,
|
||||
CRYPT_VERIFYCONTEXT)) {
|
||||
log_warn(LD_CRYPTO, "Unable to set Windows CryptoAPI provider [1].");
|
||||
log_notice(LD_CRYPTO, "Unable to set Windows CryptoAPI provider [1].");
|
||||
return -1;
|
||||
}
|
||||
provider_set = 1;
|
||||
}
|
||||
if (!CryptGenRandom(provider, out_len, out)) {
|
||||
log_warn(LD_CRYPTO, "Unable get entropy from the Windows CryptoAPI.");
|
||||
log_notice(LD_CRYPTO, "Unable get entropy from the Windows CryptoAPI.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1951,13 +1957,13 @@ crypto_strongest_rand_syscall(uint8_t *out, size_t out_len)
|
||||
|
||||
/* Useful log message for errno. */
|
||||
if (errno == ENOSYS) {
|
||||
log_warn(LD_CRYPTO, "Can't get entropy from getrandom()."
|
||||
log_notice(LD_CRYPTO, "Can't get entropy from getrandom()."
|
||||
" You are running a version of Tor built to support"
|
||||
" getrandom(), but the kernel doesn't implement this"
|
||||
" function--probably because it is too old?"
|
||||
" Trying fallback method instead.");
|
||||
} else {
|
||||
log_warn(LD_CRYPTO, "Can't get entropy from getrandom(): %s.",
|
||||
log_notice(LD_CRYPTO, "Can't get entropy from getrandom(): %s.",
|
||||
" Trying fallback method instead."
|
||||
strerror(errno));
|
||||
}
|
||||
@ -2020,7 +2026,7 @@ crypto_strongest_rand_fallback(uint8_t *out, size_t out_len)
|
||||
if (n != out_len) {
|
||||
/* LCOV_EXCL_START
|
||||
* We can't make /dev/foorandom actually fail. */
|
||||
log_warn(LD_CRYPTO,
|
||||
log_notice(LD_CRYPTO,
|
||||
"Error reading from entropy source %s (read only %lu bytes).",
|
||||
filenames[i],
|
||||
(unsigned long)n);
|
||||
|
Loading…
Reference in New Issue
Block a user