Skip to content

Commit

Permalink
[BACKPORT 2.20][yugabyte#19733] ysql: Import 'Disable OpenSSL EVP dig…
Browse files Browse the repository at this point in the history
…est padding in pgcrypto'

Summary:
Original commit: 6b137c5 / D29734
Import upstream PG commit 'Disable OpenSSL EVP digest padding in pgcrypto'.

This is a prerequisite to upgrading OpenSSL to 3.0+.

Original Commit: 11901cd9628bf4e3b26d9aba21e6287f2cde3a8a

Original Description:

```
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
```

Upstream Commit Link: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=318df802355924015d4d8f21859bc0ef7a348970

Backport-through: 2.14
Jira: DB-8563

Test Plan: Jenkins

Reviewers: jason

Reviewed By: jason

Subscribers: jason, rthallam, yql

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D29865
  • Loading branch information
es1024 committed Nov 14, 2023
1 parent 81d2890 commit ad4f0e1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/postgres/contrib/pgcrypto/openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ gen_ossl_decrypt(PX_Cipher *c, const uint8 *data, unsigned dlen,
{
if (!EVP_DecryptInit_ex(od->evp_ctx, od->evp_ciph, NULL, NULL, NULL))
return PXE_CIPHER_INIT;
if (!EVP_CIPHER_CTX_set_padding(od->evp_ctx, 0))
return PXE_CIPHER_INIT;
if (!EVP_CIPHER_CTX_set_key_length(od->evp_ctx, od->klen))
return PXE_CIPHER_INIT;
if (!EVP_DecryptInit_ex(od->evp_ctx, NULL, NULL, od->key, od->iv))
Expand All @@ -392,6 +394,8 @@ gen_ossl_encrypt(PX_Cipher *c, const uint8 *data, unsigned dlen,
{
if (!EVP_EncryptInit_ex(od->evp_ctx, od->evp_ciph, NULL, NULL, NULL))
return PXE_CIPHER_INIT;
if (!EVP_CIPHER_CTX_set_padding(od->evp_ctx, 0))
return PXE_CIPHER_INIT;
if (!EVP_CIPHER_CTX_set_key_length(od->evp_ctx, od->klen))
return PXE_CIPHER_INIT;
if (!EVP_EncryptInit_ex(od->evp_ctx, NULL, NULL, od->key, od->iv))
Expand Down

0 comments on commit ad4f0e1

Please sign in to comment.