aboutsummaryrefslogtreecommitdiffstats
path: root/util-src
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-06-24 15:33:04 +0200
committerKim Alvefur <zash@zash.se>2022-06-24 15:33:04 +0200
commit9a960217066e2659bf9473220c977c9246bcf6fa (patch)
tree58d986e7bda3f4db17b3cdff9a58361424584610 /util-src
parenta7567a9055c959c89d00424cc9c14f64365a8a35 (diff)
downloadprosody-9a960217066e2659bf9473220c977c9246bcf6fa.tar.gz
prosody-9a960217066e2659bf9473220c977c9246bcf6fa.zip
util.hashes: Return OpenSSL error messages on failure
With luck, might contain more details than just "failed"
Diffstat (limited to 'util-src')
-rw-r--r--util-src/hashes.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/util-src/hashes.c b/util-src/hashes.c
index 1b3e157d..de802db0 100644
--- a/util-src/hashes.c
+++ b/util-src/hashes.c
@@ -28,6 +28,7 @@ typedef unsigned __int32 uint32_t;
#include <openssl/md5.h>
#include <openssl/hmac.h>
#include <openssl/evp.h>
+#include <openssl/err.h>
#if (LUA_VERSION_NUM == 501)
#define luaL_setfuncs(L, R, N) luaL_register(L, NULL, R)
@@ -85,7 +86,7 @@ static int Levp_hash(lua_State *L, const EVP_MD *evp) {
fail:
EVP_MD_CTX_free(ctx);
- return luaL_error(L, "hash function failed");
+ return luaL_error(L, ERR_error_string(ERR_get_error(), NULL));
}
static int Lsha1(lua_State *L) {
@@ -178,7 +179,7 @@ static int Levp_hmac(lua_State *L, const EVP_MD *evp) {
fail:
EVP_MD_CTX_free(ctx);
EVP_PKEY_free(pkey);
- return luaL_error(L, "hash function failed");
+ return luaL_error(L, ERR_error_string(ERR_get_error(), NULL));
}
static int Lhmac_sha1(lua_State *L) {
@@ -231,7 +232,7 @@ static int Levp_pbkdf2(lua_State *L, const EVP_MD *evp, size_t out_len) {
const int iter = luaL_checkinteger(L, 3);
if(PKCS5_PBKDF2_HMAC(pass, pass_len, salt, salt_len, iter, evp, out_len, out) == 0) {
- return luaL_error(L, "PKCS5_PBKDF2_HMAC() failed");
+ return luaL_error(L, ERR_error_string(ERR_get_error(), NULL));
}
lua_pushlstring(L, (char *)out, out_len);