mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
Add crypto_log_errors() to crypto_util.[ch]
crypto_log_errors() has been moved to crypto_util.[ch]. It was duplicated in some files so they have been removed too. Follows #24658. Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
This commit is contained in:
parent
5ad72bc1f5
commit
5b7a12d58a
@ -86,27 +86,6 @@ static int crypto_early_initialized_ = 0;
|
||||
/** Boolean: has OpenSSL's crypto been initialized? */
|
||||
static int crypto_global_initialized_ = 0;
|
||||
|
||||
/** Log all pending crypto errors at level <b>severity</b>. Use
|
||||
* <b>doing</b> to describe our current activities.
|
||||
*/
|
||||
static void
|
||||
crypto_log_errors(int severity, const char *doing)
|
||||
{
|
||||
unsigned long err;
|
||||
const char *msg, *lib, *func;
|
||||
while ((err = ERR_get_error()) != 0) {
|
||||
msg = (const char*)ERR_reason_error_string(err);
|
||||
lib = (const char*)ERR_lib_error_string(err);
|
||||
func = (const char*)ERR_func_error_string(err);
|
||||
if (!msg) msg = "(null)";
|
||||
if (!lib) lib = "(null)";
|
||||
if (!func) func = "(null)";
|
||||
if (BUG(!doing)) doing = "(null)";
|
||||
tor_log(severity, LD_CRYPTO, "crypto error while %s: %s (in %s:%s)",
|
||||
doing, msg, lib, func);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef DISABLE_ENGINES
|
||||
/** Log any OpenSSL engines we're using at NOTICE. */
|
||||
static void
|
||||
|
@ -44,27 +44,6 @@ struct crypto_pk_t
|
||||
RSA *key; /**< The key itself */
|
||||
};
|
||||
|
||||
/** Log all pending crypto errors at level <b>severity</b>. Use
|
||||
* <b>doing</b> to describe our current activities.
|
||||
*/
|
||||
static void
|
||||
crypto_log_errors(int severity, const char *doing)
|
||||
{
|
||||
unsigned long err;
|
||||
const char *msg, *lib, *func;
|
||||
while ((err = ERR_get_error()) != 0) {
|
||||
msg = (const char*)ERR_reason_error_string(err);
|
||||
lib = (const char*)ERR_lib_error_string(err);
|
||||
func = (const char*)ERR_func_error_string(err);
|
||||
if (!msg) msg = "(null)";
|
||||
if (!lib) lib = "(null)";
|
||||
if (!func) func = "(null)";
|
||||
if (BUG(!doing)) doing = "(null)";
|
||||
tor_log(severity, LD_CRYPTO, "crypto error while %s: %s (in %s:%s)",
|
||||
doing, msg, lib, func);
|
||||
}
|
||||
}
|
||||
|
||||
/** Return the number of bytes added by padding method <b>padding</b>.
|
||||
*/
|
||||
int
|
||||
|
@ -27,10 +27,13 @@
|
||||
|
||||
DISABLE_GCC_WARNING(redundant-decls)
|
||||
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
ENABLE_GCC_WARNING(redundant-decls)
|
||||
|
||||
#include "torlog.h"
|
||||
|
||||
/**
|
||||
* Destroy the <b>sz</b> bytes of data stored at <b>mem</b>, setting them to
|
||||
* the value <b>byte</b>.
|
||||
@ -103,5 +106,22 @@ memwipe(void *mem, uint8_t byte, size_t sz)
|
||||
memset(mem, byte, sz);
|
||||
}
|
||||
|
||||
void
|
||||
crypto_log_errors(int severity, const char *doing)
|
||||
{
|
||||
unsigned long err;
|
||||
const char *msg, *lib, *func;
|
||||
while ((err = ERR_get_error()) != 0) {
|
||||
msg = (const char*)ERR_reason_error_string(err);
|
||||
lib = (const char*)ERR_lib_error_string(err);
|
||||
func = (const char*)ERR_func_error_string(err);
|
||||
if (!msg) msg = "(null)";
|
||||
if (!lib) lib = "(null)";
|
||||
if (!func) func = "(null)";
|
||||
if (BUG(!doing)) doing = "(null)";
|
||||
tor_log(severity, LD_CRYPTO, "crypto error while %s: %s (in %s:%s)",
|
||||
doing, msg, lib, func);
|
||||
}
|
||||
}
|
||||
#endif /* !defined(CRYPTO_UTIL_PRIVATE) */
|
||||
|
||||
|
@ -18,6 +18,9 @@
|
||||
/** OpenSSL-based utility functions. */
|
||||
void memwipe(void *mem, uint8_t byte, size_t sz);
|
||||
|
||||
/** Log utility function */
|
||||
void crypto_log_errors(int severity, const char *doing);
|
||||
|
||||
#ifdef CRYPTO_UTIL_PRIVATE
|
||||
#ifdef TOR_UNIT_TESTS
|
||||
#endif /* defined(TOR_UNIT_TESTS) */
|
||||
|
@ -78,29 +78,6 @@ show_help(void)
|
||||
"[--passphrase-fd <fd>]\n");
|
||||
}
|
||||
|
||||
/* XXXX copied from crypto.c */
|
||||
static void
|
||||
crypto_log_errors(int severity, const char *doing)
|
||||
{
|
||||
unsigned long err;
|
||||
const char *msg, *lib, *func;
|
||||
while ((err = ERR_get_error()) != 0) {
|
||||
msg = (const char*)ERR_reason_error_string(err);
|
||||
lib = (const char*)ERR_lib_error_string(err);
|
||||
func = (const char*)ERR_func_error_string(err);
|
||||
if (!msg) msg = "(null)";
|
||||
if (!lib) lib = "(null)";
|
||||
if (!func) func = "(null)";
|
||||
if (doing) {
|
||||
tor_log(severity, LD_CRYPTO, "crypto error while %s: %s (in %s:%s)",
|
||||
doing, msg, lib, func);
|
||||
} else {
|
||||
tor_log(severity, LD_CRYPTO, "crypto error: %s (in %s:%s)",
|
||||
msg, lib, func);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Read the passphrase from the passphrase fd. */
|
||||
static int
|
||||
load_passphrase(void)
|
||||
|
Loading…
Reference in New Issue
Block a user