Re: Modern SHA2- based password hashes for pgcrypto

2025-04-10 Thread Bernd Helmle
Am Sonntag, dem 06.04.2025 um 15:43 -0400 schrieb Tom Lane: > What this is on about is that portable use of isalpha() or isdigit() > requires casting a "char" value to "unsigned char".  I was about to > make that simple change when I started to question if we actually > want to be using here at al

Re: Modern SHA2- based password hashes for pgcrypto

2025-04-10 Thread Tom Lane
Bernd Helmle writes: > Here is a patch that tries to address all these issues (including > Andres' report). I've adjusted the error message and use ereport(), so > it might be more useful if we deal with not just single byte letters. I'd like to get mamba back to green, so I'll take care of this

Re: Modern SHA2- based password hashes for pgcrypto

2025-04-08 Thread Andres Freund
Hi, On 2025-04-07 09:09:39 +0200, Bernd Helmle wrote: > Am Sonntag, dem 06.04.2025 um 23:02 -0400 schrieb Andres Freund: > > On 2025-04-05 19:22:58 +0200, Alvaro Herrera wrote: > > > I have pushed this now, hoping it won't explode. > > > > I have a WIP patch that adds gcc specific allocator attri

Re: Modern SHA2- based password hashes for pgcrypto

2025-04-07 Thread Tom Lane
I wrote: > Bernd Helmle writes: >> Here is a patch that tries to address all these issues (including >> Andres' report). I've adjusted the error message and use ereport(), so >> it might be more useful if we deal with not just single byte letters. > I'd like to get mamba back to green, so I'll ta

Re: Modern SHA2- based password hashes for pgcrypto

2025-04-07 Thread Álvaro Herrera
On Mon, Apr 7, 2025, at 7:50 PM, Tom Lane wrote: > I'd like to get mamba back to green, so I'll take care of this > (unless Alvaro is already on it?) Please feel free, thank you.

Re: Modern SHA2- based password hashes for pgcrypto

2025-04-07 Thread Bernd Helmle
Am Sonntag, dem 06.04.2025 um 15:43 -0400 schrieb Tom Lane: > I'd be more comfortable with a check like > > if (strchr("...valid chars...", *ep) != NULL) > > It looks like "_crypt_itoa64" might be directly usable as the > valid-chars string, too.  (BTW, why is _crypt_itoa64 not > marked con

Re: Modern SHA2- based password hashes for pgcrypto

2025-04-07 Thread Bernd Helmle
Am Sonntag, dem 06.04.2025 um 23:02 -0400 schrieb Andres Freund: > Hi, > > On 2025-04-05 19:22:58 +0200, Alvaro Herrera wrote: > > I have pushed this now, hoping it won't explode. > > I have a WIP patch that adds gcc specific allocator attributes for > palloc et > al. Just rebased that. It warns

Re: Modern SHA2- based password hashes for pgcrypto

2025-04-06 Thread Andres Freund
Hi, On 2025-04-05 19:22:58 +0200, Alvaro Herrera wrote: > I have pushed this now, hoping it won't explode. I have a WIP patch that adds gcc specific allocator attributes for palloc et al. Just rebased that. It warns on the new code as follows: [1489/1804 42 82%] Compiling C object contrib/pgcr

Re: Modern SHA2- based password hashes for pgcrypto

2025-04-06 Thread Tom Lane
Alvaro Herrera writes: > I have pushed this now, hoping it won't explode. mamba is not happy: ccache cc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compati

Re: Modern SHA2- based password hashes for pgcrypto

2025-04-06 Thread Bernd Helmle
Am Samstag, dem 05.04.2025 um 19:22 +0200 schrieb Alvaro Herrera: > Hello, > > I have pushed this now, hoping it won't explode. > > Thanks! Very cool, i keep my fingers crossed. Thanks, Bernd

Re: Modern SHA2- based password hashes for pgcrypto

2025-04-05 Thread Alvaro Herrera
Hello, I have pushed this now, hoping it won't explode. Thanks! -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "No es bueno caminar con un hombre muerto"

Re: Modern SHA2- based password hashes for pgcrypto

2025-04-05 Thread Bernd Helmle
Am Donnerstag, dem 03.04.2025 um 20:39 +0200 schrieb Alvaro Herrera: > > > Maybe, in case of empty salts, we should issue a WARNING instead of > > erroring out and put additional documentation on how to use it > > right. > > I don't know, that doesn't seem ideal to me, because it's very easy > to

Re: Modern SHA2- based password hashes for pgcrypto

2025-04-05 Thread Alvaro Herrera
Hello, I triggered a run of this on CI on all platforms. It seems to have gone well, so unless I hear complaints, I intend to get this out later today. https://cirrus-ci.com/build/4613871211642880 Thanks, -- Álvaro HerreraBreisgau, Deutschland — https://www.EnterpriseDB.com/

Re: Modern SHA2- based password hashes for pgcrypto

2025-04-03 Thread Alvaro Herrera
On 2025-Mar-11, Bernd Helmle wrote: > Please find attached v4 of this patch. I added the following changes: > > - Check for non-supported characters in the salt like passlib does. > - Check for reserved tokens when parsing the salt string (i find this > very strict, but it covers the cases Japin

Re: Modern SHA2- based password hashes for pgcrypto

2025-03-11 Thread Bernd Helmle
Hi, > I definitely like that passlib have documented their thought process > thoroughly. > Please find attached v4 of this patch. I added the following changes: - Check for non-supported characters in the salt like passlib does. - Check for reserved tokens when parsing the salt string (i find t

Re: Modern SHA2- based password hashes for pgcrypto

2025-02-07 Thread Japin Li
On Fri, 07 Feb 2025 at 10:31, Alvaro Herrera wrote: > On 2025-Feb-07, Japin Li wrote: > >> Since there is no standard, how do we handle this? I prefer to use >> the strict mode like passlib. > > I definitely like that passlib have documented their thought process > thoroughly. > > I think using t

Re: Modern SHA2- based password hashes for pgcrypto

2025-02-07 Thread Alvaro Herrera
On 2025-Feb-07, Japin Li wrote: > Since there is no standard, how do we handle this? I prefer to use > the strict mode like passlib. I definitely like that passlib have documented their thought process thoroughly. I think using their strict mode is good on principle, but if we're going to do th

Re: Modern SHA2- based password hashes for pgcrypto

2025-02-07 Thread Japin Li
On Thu, 06 Feb 2025 at 11:20, Alvaro Herrera wrote: > On 2025-Jan-28, Bernd Helmle wrote: > >> Python's passlib is very strict when it comes to supported characters >> within a salt string. It rejects everything thats not matching '[./0- >> 9A-Za-z]'. So when you provide the example above you get

Re: Modern SHA2- based password hashes for pgcrypto

2025-02-06 Thread Alvaro Herrera
On 2025-Jan-28, Bernd Helmle wrote: > Python's passlib is very strict when it comes to supported characters > within a salt string. It rejects everything thats not matching '[./0- > 9A-Za-z]'. So when you provide the example above you get The reason it uses these chars is that in their scheme the

Re: Modern SHA2- based password hashes for pgcrypto

2025-01-28 Thread Bernd Helmle
Am Freitag, dem 24.01.2025 um 19:06 +0100 schrieb Alvaro Herrera: > > So we behave exactly the same way as px_crypt_md5(): It stops after > > the > > first '$' after the magic byte preamble. For shacrypt, this could > > be > > the next '$' after the closing one of the non-mandatory 'rounds' > > opt

Re: Modern SHA2- based password hashes for pgcrypto

2025-01-26 Thread Japin Li
On Fri, 24 Jan 2025 at 19:06, Alvaro Herrera wrote: > On 2025-Jan-24, Bernd Helmle wrote: > >> So we behave exactly the same way as px_crypt_md5(): It stops after the >> first '$' after the magic byte preamble. For shacrypt, this could be >> the next '$' after the closing one of the non-mandatory

Re: Modern SHA2- based password hashes for pgcrypto

2025-01-24 Thread Bernd Helmle
Am Donnerstag, dem 23.01.2025 um 21:36 +0800 schrieb Japin Li: Thanks for your review again. I am going to work on the other items, but this one might need further discussion: > 5. > Does the following work as expected? > > postgres=# select crypt('hello', > '$5$$6$rounds=1$/Zg436s2vmTwsoSz'

Re: Modern SHA2- based password hashes for pgcrypto

2025-01-24 Thread Alvaro Herrera
On 2025-Jan-24, Bernd Helmle wrote: > So we behave exactly the same way as px_crypt_md5(): It stops after the > first '$' after the magic byte preamble. For shacrypt, this could be > the next '$' after the closing one of the non-mandatory 'rounds' > option, but with your example this doesn't happe

Re: Modern SHA2- based password hashes for pgcrypto

2025-01-23 Thread Japin Li
On Mon, 20 Jan 2025 at 18:41, Bernd Helmle wrote: > Hi, > > Please find attached a reworked patch according Alvaro's comments. > > Am Montag, dem 13.01.2025 um 17:06 +0100 schrieb Alvaro Herrera: >> Hello >> >> I was passing by and I noticed that this needs badly pgindent, and >> some >> comment

Re: Modern SHA2- based password hashes for pgcrypto

2025-01-20 Thread Bernd Helmle
Hi, Please find attached a reworked patch according Alvaro's comments. Am Montag, dem 13.01.2025 um 17:06 +0100 schrieb Alvaro Herrera: > Hello > > I was passing by and I noticed that this needs badly pgindent, and > some > comments are enumerations that would lose formatting once through it. >

Re: Modern SHA2- based password hashes for pgcrypto

2025-01-14 Thread Bernd Helmle
Am Dienstag, dem 14.01.2025 um 11:47 +0100 schrieb Alvaro Herrera: > > Oh, that's news to me. Is there a plan for it somewhere? I agree > > that > > pgcrypto is widley used and needs a proper replacement when we > > decide > > to deprecate it. > > I don't know about a plan, but > https://www.youtu

Re: Modern SHA2- based password hashes for pgcrypto

2025-01-14 Thread Alvaro Herrera
Hello Bernd, On 2025-Jan-14, Bernd Helmle wrote: > > It's been said in my presence that pgcrypto is obsolete and > > shouldn't be used anymore.  I'm not sure I believe that, but even if > > that's true, it's clear that there's plenty of people who has an > > interest on it, so I don't see that as

Re: Modern SHA2- based password hashes for pgcrypto

2025-01-14 Thread Bernd Helmle
Hi Alvaro, Am Montag, dem 13.01.2025 um 17:06 +0100 schrieb Alvaro Herrera: > Hello > > I was passing by and I noticed that this needs badly pgindent, and > some > comments are enumerations that would lose formatting once through it. > For example, this would happen which is not good: > >     /*

Re: Modern SHA2- based password hashes for pgcrypto

2025-01-13 Thread Alvaro Herrera
Hello I was passing by and I noticed that this needs badly pgindent, and some comments are enumerations that would lose formatting once through it. For example, this would happen which is not good: /* -* 1. Start digest A -* 2. Add the password string to digest A -* 3. Add the sal

Re: Modern SHA2- based password hashes for pgcrypto

2025-01-07 Thread Bernd Helmle
Am Samstag, dem 04.01.2025 um 08:19 +0800 schrieb Japin Li: > (gdb) bt > #0  __pthread_kill_implementation (no_tid=0, signo=6, > threadid=) at ./nptl/pthread_kill.c:44 > #1  __pthread_kill_internal (signo=6, threadid=) at > ./nptl/pthread_kill.c:78 > #2  __GI___pthread_kill (threadid=, > signo=sign

Re: Modern SHA2- based password hashes for pgcrypto

2025-01-03 Thread Japin Li
On Fri, 03 Jan 2025 at 17:55, Bernd Helmle wrote: > Am Freitag, dem 03.01.2025 um 23:57 +0800 schrieb Japin Li: >> >> Greate!  I have some questions after using it. >> >> When I use the following query, it crashed! >> >> [local]:4012204 postgres=# select crypt('hello', >> '$5$$6$rounds=1$/Z

Re: Modern SHA2- based password hashes for pgcrypto

2025-01-03 Thread Bernd Helmle
Am Freitag, dem 03.01.2025 um 23:57 +0800 schrieb Japin Li: > > Greate!  I have some questions after using it. > > When I use the following query, it crashed! > > [local]:4012204 postgres=# select crypt('hello', > '$5$$6$rounds=1$/Zg436s2vmTwsoSz'); > server closed the connection unexpectedl

Re: Modern SHA2- based password hashes for pgcrypto

2025-01-03 Thread Japin Li
On Tue, 31 Dec 2024 at 17:06, Bernd Helmle wrote: > 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 b

Re: Modern SHA2- based password hashes for pgcrypto

2025-01-02 Thread Daniel Gustafsson
> On 2 Jan 2025, at 16:17, Bernd Helmle wrote: > > Am Donnerstag, dem 02.01.2025 um 15:57 +0100 schrieb Daniel Gustafsson: >>> I adapted the code from the publicly available reference >>> implementation >>> at [1]. It's based on our existing OpenSSL infrastructure in >>> pgcrypto >>> and produces

Re: Modern SHA2- based password hashes for pgcrypto

2025-01-02 Thread Bernd Helmle
Am Donnerstag, dem 02.01.2025 um 15:57 +0100 schrieb Daniel Gustafsson: > > 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

Re: Modern SHA2- based password hashes for pgcrypto

2025-01-02 Thread Daniel Gustafsson
> On 31 Dec 2024, at 17:06, Bernd Helmle wrote: > 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" switch

Re: Modern SHA2- based password hashes for pgcrypto

2024-12-31 Thread Bernd Helmle
Am Dienstag, dem 31.12.2024 um 17:06 +0100 schrieb Bernd Helmle: > I am going to add this patch to the upcoming january commitfest for > initial review. I see cfbot fails Debian Bookworm with autoconf and on macOS with meson. I will look into it.

Modern SHA2- based password hashes for pgcrypto

2024-12-31 Thread Bernd Helmle
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