Modern SHA2- based password hashes for pgcrypto

From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Modern SHA2- based password hashes for pgcrypto
Date: 2024-12-31 16:06:35
Message-ID: c763235a2757e2f5f9e3e27268b9028349cef659.camel@oopsware.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Hackers,

Some of you might already arrived 2025, so first a Happy New Year to
everyone already there ;)

Please find attached a patch to pgcrypto to add modern SHA-2 based
password hashes sha256crypt (256 bit) and sha512crypt (512 bit) for
crypt() and gen_salt() respectively. This is compatible on what crypt()
currently does on FreeBSD and Linux and both algorithms are considered
more secure than the currently implemented hashes.

I adapted the code from the publicly available reference implementation
at [1]. It's based on our existing OpenSSL infrastructure in pgcrypto
and produces compatible password hashes with crypt() and "openssl
passwd" with "-5" and "-6" switches.

I documented the new supported hashes for pgcrypto, but didn't do
anything to update the benchmark table for the supported password
hashes.

Modern OS (at least Linux, BSDs) implementations for crypt() also
support yescrypt, which is the recommended (and default) password hash
algorithm there. I am also looking to implement that, but thought it
would be useful to have the SHA-2 based hashes first in the review.

I am going to add this patch to the upcoming january commitfest for
initial review.

[1] https://www.akkadia.org/drepper/SHA-crypt.txt

--
Thanks,
Bernd

Attachment Content-Type Size
0001-Add-modern-SHA-2-based-password-hashes-to-pgcrypto.patch text/x-patch 31.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2024-12-31 16:09:42 Re: using index to speedup add not null constraints to a table
Previous Message Sami Imseih 2024-12-31 15:53:54 Re: add vacuum starttime columns