Re: Documentation of pgcrypto AES key sizes
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Michael Paquier <michael.paquier@gmail.com>
Cc: Thomas Munro <thomas.munro@enterprisedb.com>, Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2018-01-26T15:56:49Z
Lists: pgsql-hackers
On Thu, Jan 25, 2018 at 8:19 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:
> On Fri, Jan 26, 2018 at 12:33:41PM +1300, Thomas Munro wrote:
>> I noticed that the documentation for encrypt()/decrypt() says "aes —
>> AES (Rijndael-128)", but in fact 192 and 256 bit keys are also
>> supported, whether you build --with-openssl or --without-openssl.
>> Should that say "AES (Rijndael-128, -192 or -256)" instead?
>
> Indeed. Instead of using the keysize as a prefix, I would personally
> find less confusing if written as "AES (Rijndael with key sizes of 128,
> 192 or 256 bytes)" instead of the phrasing you are proposing. Well, it
> is true that "Rijndael-128" and friends are wordings that can be found
> here and there..
encrypt() seems happy with a key of any length at all, although I
guess internally it must round up to the next larger size.
rhaas=# select v, min(n), max(n) from (select n, encrypt('hello
world'::bytea, ('\x' || repeat('00', n))::bytea, 'aes') v from
generate_series(1,100000) n) x group by 1;
v | min | max
------------------------------------+-----+--------
\x7489adda96bb9c30fb4932e07731571a | 1 | 16
\x20a25e2af113663852f4e7b7870835ff | 17 | 24
\x56cbe187babf7b5df62924d78a3a5099 | 25 | 100000
(3 rows)
The breakpoints are at 16 bytes = 128 bits and 24 bytes = 192 bits, so
that is consistent with Thomas's theory about what's going on under
the hood.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Commits
-
pgcrypto's encrypt() supports AES-128, AES-192, and AES-256
- 4ab8ded9fb4e 9.3.21 landed
- 7c348e16c279 9.4.16 landed
- 71bf5bc2c406 9.5.11 landed
- 7201c68793e9 9.6.7 landed
- d40d97d6c744 11.0 landed
- 1787c332dbb7 10.2 landed