Software /
code /
prosody
Changeset
12565:2e0c7f5cd8f8
util.hashes: Return OpenSSL error messages on failure
With luck, might contain more details than just "failed"
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 24 Jun 2022 15:33:04 +0200 |
parents | 12564:36e769c64054 |
children | 12566:91e5cb295ba3 |
files | util-src/hashes.c |
diffstat | 1 files changed, 4 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/util-src/hashes.c Thu Sep 10 21:58:24 2020 +0200 +++ b/util-src/hashes.c Fri Jun 24 15:33:04 2022 +0200 @@ -28,6 +28,7 @@ #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 @@ 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 @@ 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 @@ 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);