🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #90067

Re: Modern encryption for INN's ckpasswd or equivalent options?

#90067
From: Julien ÉLIE
Date: Sat, 04 Feb 2023 10:14
80 lines
4960 bytes
Hi Jesse and Russ,

Thanks for this discussion, it was pretty interesting.

>>> How can I tell what algorithms my library supports?
>>
>> man 3 crypt should hopefully tell you what the available hash algorithms
>> are.

"man 3 crypt" does not indicate the available hash schemes on my system (Debian bullseye).
Looking at the libcrypt-dev package which provides it, I see it installs both crypt.3 and crypt.5 man pages.  The source package is libxcrypt even though it is libcrypt-dev (and not libxcrypt-dev).
Available hash schemes are found in "man 5 crypt" in Debian (but "man 3 crypt" in FreeBSD).



>> https://man.freebsd.org/cgi/man.cgi?crypt(3) seems to imply nothing better
>> than SHA-512 is supported, which is a bit surprising.

I confirm that on FreeBSD 13, the Perl crypt() function which uses the system crypt(3) one does not recognize yescript.



> Auth works if I use the following for MD5:
> 
>     openssl passwd -1 -salt xyz somepassword
> 
> Or the following for SHA512:
> 
>     openssl passwd -6 -salt xyz somepassword

I'll remove the mention of htpasswd from the ckpasswd man page, and modernize the wording.
Here is what I came up with.  I hope it will be of help for other people looking at how to generate passwords.

     -f filename
         Read passwords from the given file rather than using getpwnam(3).
         Each line of the file should look something like:

             username:$5$Hlb2yXPd$2nOO/QR9P1mnRFr/i6L9ybxbgSDXd4UlatKqbcY4eoB
             joe:FCjOJnpOo50IE:Old weak hash algorithm used for Joe

         Each line has at least two fields separated by a colon.  The first
         field contains the username; the second field contains a password
         hashed with the crypt(3) function.  Additional colons and data may
         appear after the encrypted password; that data will be ignored by
         ckpasswd.  Lines starting with a number sign ("#") are ignored.

         INN does not come with a utility to create the encrypted passwords,
         but OpenSSL can do so and it's also a quick job with Perl (see the
         one-line example script below).

         A line in *filename* for the user "user" with the password "pass"
         would be "user:" followed with the output of the following command
         using SHA-256 as hashing scheme:

             % openssl passwd -5 pass
             $5$UIhtJSBOaC0Ap3Vk$nbKgmykshoQ2HmvA3s/nI.X4uhhNHBKTYhBS3pYLjJ6

         See the openssl-passwd(1) man page for the list of hashing schemes
         it can generate.  You must take one that your system crypt(3)
         function handles (type "man 3 crypt" or "man 5 crypt" to find the
         supported hashing schemes).

         In case OpenSSL is not installed on your server, you can also use
         the following Perl command which does the same job:

             % perl -le "print crypt('pass', '\$5\$UIhtJSBOaC0Ap3Vk\$');"
             $5$UIhtJSBOaC0Ap3Vk$nbKgmykshoQ2HmvA3s/nI.X4uhhNHBKTYhBS3pYLjJ6

         As Perl makes use of crypt(3), you have access to all available
         hashing schemes on your systems (like yescript, if supported).  Make
         sure to use a random salt.

             % perl -le "print crypt('pass', '\$y\$j9T\$YourSalt\$');"
             $y$j9T$YourSalt$X4tB48vKNDT6mK0vNOc7ppKPWvEsyMg5LwoQfO50r2A

-- 
Julien ÉLIE

« Le sel de l'existence est essentiellement dans le poivre qu'on y
   met. » (Alphonse Allais)
Technical Details
Message-ID: <trlb5t$k5qt$1@news.trigofacile.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!apf1.newsdeef.eu!not-for-mail
References: <tr3s1v$peb$1@nnrp.usenet.blueworldhosting.com> <87sffutqdx.fsf@hope.eyrie.org> <tr3tns$qg3$1@nnrp.usenet.blueworldhosting.com> <87k016tops.fsf@hope.eyrie.org> <tr4tmr$224f$1@nnrp.usenet.blueworldhosting.com>

Show Full Headers
Complete Article Headers
Message-ID: <trlb5t$k5qt$1@news.trigofacile.com>
Subject: Re: Modern encryption for INN's ckpasswd or equivalent options?
Date: Sat, 4 Feb 2023 11:14:21 +0100
From: Julien ÉLIE <iulius@nom-de-mon-site.com.invalid>
References: <tr3s1v$peb$1@nnrp.usenet.blueworldhosting.com> <87sffutqdx.fsf@hope.eyrie.org> <tr3tns$qg3$1@nnrp.usenet.blueworldhosting.com> <87k016tops.fsf@hope.eyrie.org> <tr4tmr$224f$1@nnrp.usenet.blueworldhosting.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!apf1.newsdeef.eu!not-for-mail
Newsgroups: news.software.nntp
Organization: Groupes francophones par TrigoFACILE
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 4 Feb 2023 10:14:21 -0000 (UTC)
Injection-Info: news.trigofacile.com; posting-account="julien"; posting-host="176-143-2-105.abo.bbox.fr:176.143.2.105"; logging-data="661341"; mail-complaints-to="abuse@trigofacile.com"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.1
Cancel-Lock: sha1:TE/Ubhlt8OnpSN+PDt5PKYQ/9rY= sha256:h73xq6lpq/3BhfY0JkHz9w9bdVBUwym+w1aNIDG3VVE= sha1:0toYQeAtesJ7ue7/XVoiJVisXRk= sha256:28F4ntGJjvlCrdHU0uX9MHQmB3rP97PCs1OkaqtwFSk=
In-Reply-To: <tr4tmr$224f$1@nnrp.usenet.blueworldhosting.com>