|
@@ -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) */
|
|
|
|