Skip to content

Commit 00c72da

Browse files
Disable OpenSSL EVP digest padding in pgcrypto
The PX layer in pgcrypto is handling digest padding on its own uniformly for all backend implementations. Starting with OpenSSL 3.0.0, DecryptUpdate doesn't flush the last block in case padding is enabled so explicitly disable it as we don't use it. This will be backpatched to all supported version once there is sufficient testing in the buildfarm of OpenSSL 3. Reviewed-by: Peter Eisentraut, Michael Paquier Discussion: https://postgr.es/m/FEF81714-D479-4512-839B-C769D2605F8A@yesql.se Backpatch-through: 9.6
1 parent 90cfd26 commit 00c72da

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

contrib/pgcrypto/openssl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ gen_ossl_decrypt(PX_Cipher *c, const uint8 *data, unsigned dlen,
380380
{
381381
if (!EVP_DecryptInit_ex(od->evp_ctx, od->evp_ciph, NULL, NULL, NULL))
382382
return PXE_CIPHER_INIT;
383+
if (!EVP_CIPHER_CTX_set_padding(od->evp_ctx, 0))
384+
return PXE_CIPHER_INIT;
383385
if (!EVP_CIPHER_CTX_set_key_length(od->evp_ctx, od->klen))
384386
return PXE_CIPHER_INIT;
385387
if (!EVP_DecryptInit_ex(od->evp_ctx, NULL, NULL, od->key, od->iv))
@@ -404,6 +406,8 @@ gen_ossl_encrypt(PX_Cipher *c, const uint8 *data, unsigned dlen,
404406
{
405407
if (!EVP_EncryptInit_ex(od->evp_ctx, od->evp_ciph, NULL, NULL, NULL))
406408
return PXE_CIPHER_INIT;
409+
if (!EVP_CIPHER_CTX_set_padding(od->evp_ctx, 0))
410+
return PXE_CIPHER_INIT;
407411
if (!EVP_CIPHER_CTX_set_key_length(od->evp_ctx, od->klen))
408412
return PXE_CIPHER_INIT;
409413
if (!EVP_EncryptInit_ex(od->evp_ctx, NULL, NULL, od->key, od->iv))

0 commit comments

Comments
 (0)