Thread

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

    PG Bug reporting form <noreply@postgresql.org> — 2025-11-27T08:55:14Z

    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?