21b8d7a
Upstream patch: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=135d8687ad
21b8d7a
author	Daniel Gustafsson <dgustafsson@postgresql.org>
21b8d7a
21b8d7a
The PX layer in pgcrypto is handling digest padding on its own uniformly
21b8d7a
for all backend implementations. Starting with OpenSSL 3.0.0, DecryptUpdate
21b8d7a
doesn't flush the last block in case padding is enabled so explicitly
21b8d7a
disable it as we don't use it.
21b8d7a
21b8d7a
This will be backpatched to all supported version once there is sufficient
21b8d7a
testing in the buildfarm of OpenSSL 3.
21b8d7a
21b8d7a
diff -ur postgresql-14rc1/contrib/pgcrypto/openssl.c postgresql-p/contrib/pgcrypto/openssl.c
21b8d7a
--- postgresql-14rc1/contrib/pgcrypto/openssl.c	2021-09-20 17:33:01.000000000 -0400
21b8d7a
+++ postgresql-p/contrib/pgcrypto/openssl.c	2021-10-06 04:07:24.628836908 -0400
21b8d7a
@@ -379,6 +379,8 @@
21b8d7a
 	{
21b8d7a
 		if (!EVP_DecryptInit_ex(od->evp_ctx, od->evp_ciph, NULL, NULL, NULL))
21b8d7a
 			return PXE_CIPHER_INIT;
21b8d7a
+		 if (!EVP_CIPHER_CTX_set_padding(od->evp_ctx, 0))
21b8d7a
+           		return PXE_CIPHER_INIT;
21b8d7a
 		if (!EVP_CIPHER_CTX_set_key_length(od->evp_ctx, od->klen))
21b8d7a
 			return PXE_CIPHER_INIT;
21b8d7a
 		if (!EVP_DecryptInit_ex(od->evp_ctx, NULL, NULL, od->key, od->iv))
21b8d7a
@@ -403,6 +405,8 @@
21b8d7a
 	{
21b8d7a
 		if (!EVP_EncryptInit_ex(od->evp_ctx, od->evp_ciph, NULL, NULL, NULL))
21b8d7a
 			return PXE_CIPHER_INIT;
21b8d7a
+		if (!EVP_CIPHER_CTX_set_padding(od->evp_ctx, 0))
21b8d7a
+           		return PXE_CIPHER_INIT;
21b8d7a
 		if (!EVP_CIPHER_CTX_set_key_length(od->evp_ctx, od->klen))
21b8d7a
 			return PXE_CIPHER_INIT;
21b8d7a
 		if (!EVP_EncryptInit_ex(od->evp_ctx, NULL, NULL, od->key, od->iv))
21b8d7a