BUG #19335: the function encrypt does not work correct - ERROR: encrypt error: Key was too big

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: marco(dot)lebahn(at)kfw(dot)de
Subject: BUG #19335: the function encrypt does not work correct - ERROR: encrypt error: Key was too big
Date: 2025-11-27 08:55:14
Message-ID: 19335-0ba21e6ccf61a219@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 19335
Logged by: Marco Lebahn
Email address: marco(dot)lebahn(at)kfw(dot)de
PostgreSQL version: 16.11
Operating system: SUSE Linux Enterprise Server 15 SP7
Description:

Hello,

we patched our Systems from 16.10 and 14.19 to the new minor-level 16.11 and
14.20.

No problems with 16.10 and 14.19 while we using the function encrypt and
decrypt

psql (16.10)
Type "help" for help.

postgres=# SELECT encrypt('sdafgsdfgsdafgasdf', 'thelongkeyfoobar', 'bf');
encrypt
----------------------------------------------------
\x74a761b105fbc8f535f666e952e00018deb1349fbf27a87b
(1 row)

postgres=# SELECT
convert_from(decrypt('\x74a761b105fbc8f535f666e952e00018deb1349fbf27a87b',
'thelongkeyfoobar', 'bf'),'SQL_ASCII');
convert_from
--------------------
sdafgsdfgsdafgasdf
(1 row)

postgres=#

After patching the function throws errors

postgres=# SELECT encrypt('sdafgsdfgsdafgasdf', 'thelongkeyfoobar', 'bf');
ERROR: encrypt error: Cipher cannot be initialized
postgres=# SELECT
convert_from(decrypt('\x74a761b105fbc8f535f666e952e00018deb1349fbf27a87b',
'thelongkeyfoobar', 'bf'),'SQL_ASCII');
ERROR: decrypt error: Cipher cannot be initialized
postgres=#

or here an other error

with 16.10 - No trouble
psql (16.10)
Type "help" for help.

postgres=# SELECT encrypt('sdafgsdfgsdafgasdf', 'thelongkeyfoobar1234',
'bf');
encrypt
----------------------------------------------------
\x9e8f9e9319266c9722f5803684c29ab16ee98d100cbfe350
(1 row)

trouble with 16.11

psql (16.11)
Type "help" for help.

postgres=# SELECT encrypt('sdafgsdfgsdafgasdf', 'thelongkeyfoobar1234',
'bf');
ERROR: encrypt error: Key was too big
postgres=# SELECT
convert_from(decrypt('\x9e8f9e9319266c9722f5803684c29ab16ee98d100cbfe350',
'thelongkeyfoobar1234', 'bf'),'SQL_ASCII');
ERROR: decrypt error: Key was too big
postgres=#

Is this a bug?

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2025-11-27 10:18:06 BUG #19336: TRAP: failed Assert("!IsTransactionOrTransactionBlock()")
Previous Message Amit Langote 2025-11-27 01:25:36 Re: BUG #19099: Conditional DELETE from partitioned table with non-updatable partition raises internal error