From 3d58f927eb9763c9803ce41ff6b1442289b65b8e Mon Sep 17 00:00:00 2001 From: Daniel Gustafsson Date: Thu, 29 Oct 2020 22:04:46 +0100 Subject: [PATCH] Use a more descriptive error for failed encryption We already return PXE_DECRYPT_FAILED for decryption errors, so using PXE_ERR_GENERIC for encryption errors isn't really consistent or for that matter helpful. --- contrib/pgcrypto/openssl.c | 2 +- contrib/pgcrypto/px.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/pgcrypto/openssl.c b/contrib/pgcrypto/openssl.c index ed96e4ce53..5ebe213406 100644 --- a/contrib/pgcrypto/openssl.c +++ b/contrib/pgcrypto/openssl.c @@ -400,7 +400,7 @@ gen_ossl_encrypt(PX_Cipher *c, const uint8 *data, unsigned dlen, } if (!EVP_EncryptUpdate(od->evp_ctx, res, &outlen, data, dlen)) - return PXE_ERR_GENERIC; + return PXE_ENCRYPT_FAILED; return 0; } diff --git a/contrib/pgcrypto/px.c b/contrib/pgcrypto/px.c index 6a4681dae9..a243f575d3 100644 --- a/contrib/pgcrypto/px.c +++ b/contrib/pgcrypto/px.c @@ -58,6 +58,7 @@ static const struct error_desc px_err_list[] = { {PXE_MCRYPT_INTERNAL, "mcrypt internal error"}, {PXE_NO_RANDOM, "Failed to generate strong random bits"}, {PXE_DECRYPT_FAILED, "Decryption failed"}, + {PXE_ENCRYPT_FAILED, "Encryption failed"}, {PXE_PGP_CORRUPT_DATA, "Wrong key or corrupt data"}, {PXE_PGP_CORRUPT_ARMOR, "Corrupt ascii-armor"}, {PXE_PGP_UNSUPPORTED_COMPR, "Unsupported compression algorithm"}, -- 2.21.1 (Apple Git-122.3)