From 749a9e20c9790006f3af47f7a8faf4ad8dc358d9 Mon Sep 17 00:00:00 2001 From: Álvaro Herrera Date: Sat, 5 Apr 2025 19:16:58 +0200 Subject: Add modern SHA-2 based password hashes to pgcrypto. This adapts the publicly available reference implementation on https://www.akkadia.org/drepper/SHA-crypt.txt and adds the new hash algorithms sha256crypt and sha512crypt to crypt() and gen_salt() respectively. Author: Bernd Helmle Reviewed-by: Japin Li Discussion: https://postgr.es/m/c763235a2757e2f5f9e3e27268b9028349cef659.camel@oopsware.de --- doc/src/sgml/pgcrypto.sgml | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'doc/src') diff --git a/doc/src/sgml/pgcrypto.sgml b/doc/src/sgml/pgcrypto.sgml index f87668dfaed..b567b5c16e8 100644 --- a/doc/src/sgml/pgcrypto.sgml +++ b/doc/src/sgml/pgcrypto.sgml @@ -189,6 +189,29 @@ hmac(data bytea, key bytea, type text) returns bytea 13 Original UNIX crypt + + sha256crypt + unlimited + yes + up to 32 + 80 + Adapted from publicly available reference implementation + Unix crypt using SHA-256 and SHA-512 + + + + + sha512crypt + unlimited + yes + up to 32 + 123 + Adapted from publicly available reference implementation + Unix crypt using SHA-256 and SHA-512 + + + + @@ -245,7 +268,9 @@ gen_salt(type text [, iter_count integer ]) returns text The type parameter specifies the hashing algorithm. The accepted types are: des, xdes, - md5 and bf. + md5, bf, sha256crypt and + sha512crypt. The last two, sha256crypt and + sha512crypt are modern SHA-2 based password hashes. @@ -284,6 +309,12 @@ gen_salt(type text [, iter_count integer ]) returns text 4 31 + + sha256crypt, sha512crypt + 5000 + 1000 + 999999999 + @@ -313,6 +344,14 @@ gen_salt(type text [, iter_count integer ]) returns text gen_salt. + + The default iter_count for sha256crypt and + sha512crypt of 5000 is considered too low for modern + hardware, but can be adjusted to generate stronger password hashes. + Otherwise both hashes, sha256crypt and sha512crypt are + considered safe. + + Hash Algorithm Speeds -- cgit v1.2.3