@@ -70,7 +70,9 @@ struct swupdate_digest *swupdate_DECRYPT_init(unsigned char *key, unsigned char
*/
ret = EVP_DecryptInit_ex(SSL_GET_CTXDEC(dgst), cipher, NULL, key, iv);
if (ret != 1) {
- ERROR("Decrypt Engine not initialized, error 0x%lx\n", ERR_get_error());
+ const char *reason = ERR_reason_error_string(ERR_peek_error());
+ ERROR("Decrypt Engine not initialized, error 0x%lx, reason: %s\n", ERR_get_error(),
+ reason != NULL ? reason : "unknown");
free(dgst);
return NULL;
}
@@ -82,7 +84,9 @@ int swupdate_DECRYPT_update(struct swupdate_digest *dgst, unsigned char *buf,
int *outlen, unsigned char *cryptbuf, int inlen)
{
if (EVP_DecryptUpdate(SSL_GET_CTXDEC(dgst), buf, outlen, cryptbuf, inlen) != 1) {
- ERROR("Update: Decryption error 0x%lx\n", ERR_get_error());
+ const char *reason = ERR_reason_error_string(ERR_peek_error());
+ ERROR("Update: Decryption error 0x%lx, reason: %s\n", ERR_get_error(),
+ reason != NULL ? reason : "unknown");
return -EFAULT;
}
@@ -96,8 +100,9 @@ int swupdate_DECRYPT_final(struct swupdate_digest *dgst, unsigned char *buf,
return -EINVAL;
if (EVP_DecryptFinal_ex(SSL_GET_CTXDEC(dgst), buf, outlen) != 1) {
- ERROR("Decryption error 0x%s\n",
- ERR_reason_error_string(ERR_get_error()));
+ const char *reason = ERR_reason_error_string(ERR_peek_error());
+ ERROR("Final: Decryption error 0x%lx, reason: %s\n", ERR_get_error(),
+ reason != NULL ? reason : "unknown");
return -EFAULT;
}
@@ -63,6 +63,7 @@ struct swupdate_digest {
do { \
CRYPTO_malloc_init(); \
OpenSSL_add_all_algorithms(); \
+ ERR_load_crypto_strings(); \
} while (0); \
}
#else