From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: marco.lebahn@kfw.de
Subject: BUG #19335: the function encrypt does not work correct - ERROR: encrypt error: Key was too big
Date: Thu, 27 Nov 2025 08:55:14 +0000
Message-ID: <19335-0ba21e6ccf61a219@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 19335
Logged by: Marco Lebahn
Email address: marco.lebahn@kfw.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?
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, marco.lebahn@kfw.de
Subject: Re: BUG #19335: the function encrypt does not work correct - ERROR: encrypt error: Key was too big
In-Reply-To: <19335-0ba21e6ccf61a219@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox