[musl] Re: [PATCH v1] man/man3/crypt.3: These functions accept many algorithms, not only DES
Alejandro Colomar
alx+linux-man@kernel.org
Thu Nov 12 14:58:30 GMT 2026
Hi Rich,
> Date: 2026-11-12 09:43:49-0500
> From: Rich Felker <dalias@libc.org>
>
[...]
> > But is the POSIX specification really useful for applications?
>
> Yes. It tells you enough to validate a password for authentication
> purposes:
>
> const char *result = crypt(password, hash);
> if (result && strcmp(result, hash)==0) {
> /* password validated */
> }
Is this really specified by POSIX?
Unless I'm missing something, I only see something about it in EXAMPLES,
which is non-normative, and it doesn't even explain that this is the
only way to do it correctly, but rather as a possible example. Notably,
I don't find any text that says that passing a different hash as salt
could potentially result in a hash that matches the stored hash.
That is, I don't see any text (normative or non-normative) in the POSIX
specification that implies this:
When comparing a password against an existing hash, that
hash (and no other) must be passed as salt. If and only
if salt compares equal (see streq(3)) to the returned
string, the password matches the existing hash specified
by salt.
The example is useful, but I'd say it's not enough. I think the example
should contain wording like that one above (which we're discussing in
the other thread for the manual page).
Cheers,
alex
[...]
>
> > An application should not rely on the specified return value either.
>
> It can rely on it for validating passwords against existing hashes.
> That is the more usual application need. Setting new passwords is
> usually an administrative task, except for non-system uses like making
> .htaccess files.
>
> Rich
--
<https://www.alejandro-colomar.es>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20261112/5760ec43/attachment.sig>
More information about the Libc-alpha
mailing list