Repository navigation
Conversation
yescrypt is the default on Fedora, Debian and others, but mksalt() can't make a valid salt for it, so let libxcrypt's crypt_gensalt() build the setting. The default method stays SHA-512.
|
Thank you. I am not sure if we want to accept this here. The README explicitly said:
For example, anaconda uses crypt_r for yescrypt this way: https://github.com/rhinstaller/anaconda/blob/7c8f9520e5d5a40c8beec6a5b3932b3f45c0376c/pyanaconda/core/users.py#L52 That does not seem too bad, does it? I do not think that evrybody should copypasta their code, but I don't want to add new methods here either. What is your main motivation to add this? |
|
Mainly to unify several local scripts that each duplicate salt generation, and getting the salt wrong is much easier for yescrypt than for the other algorithms. I don't have strong opinions on this PR. It's just that this is the only maintained (I think) library that uses libc/libxcrypt crypt() directly, and it already verifies yescrypt hashes just fine (when the underlying crypt() supports yescrypt). Only creating them needs a hand-built salt. |
|
cc @encukou @hrnciar @frenzymadness @stratakis @befeleme @vstinner What do you think about adding yescrypt? Generally, I do not want to add new features here, but if this was still in CPython, this would be a reasonable addition. It is after all the default on Fedora anyway. |
|
I don't think that https://github.com/fedora-python/crypt_r is the good home to add new yescrypt method. There other other projects which more actively maintained, such as:
|
So, it seems no one else picked up wrapping
|
Distros like Fedora, Debian and others use yescrypt by default, but there is no maintained Python library that creates such hashes through the system's crypt() (libxcrypt). Going through crypt() keeps the hashes consistent with PAM, shadow and everything else on the box. crypt_r already verifies "$y$" hashes, it just can't create them, hence this very simple PR (which I think is acceptable for a library that is mostly in maintenance mode).
It adds "METHOD_YESCRYPT". The salt and cost come from libxcrypt's "crypt_gensalt()", because yescrypt needs a specially encoded salt that mksalt()'s random characters don't give. "rounds" is libxcrypt's cost (1-11).
It's backward compatible: existing methods and hashes work exactly as before, and the default stays SHA-512, because the new method is listed after the SHA-2 ones (as Blowfish is). Without "crypt_gensalt()" the new method isn't listed in "methods" at all.
Tested with tox (py311-py315) on Fedora.