Re: Documentation of pgcrypto AES key sizes - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Documentation of pgcrypto AES key sizes
Date
Msg-id CA+TgmoahfPW3nZoGbWVk-6xVCKzM4vqozWAoubQ9u4JE4p0q8w@mail.gmail.com
Whole thread Raw
In response to Re: Documentation of pgcrypto AES key sizes  (Michael Paquier <michael.paquier@gmail.com>)
Responses Re: Documentation of pgcrypto AES key sizes
List 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


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [HACKERS] Patch: Add --no-comments to skip COMMENTs with pg_dump
Next
From: Stephen Frost
Date:
Subject: Re: Boolean partitions syntax