I am writing code to validate entered user passwords against hashes
served up from /etc/shadow via LDAP. I had previously used passlib <https://passlib.readthedocs.io> to do the hashing. But now I discover
it is not keeping up; for example, Debian and other distros are now
using yescrypt (hashes with “$y$” prefix), but passlib has no support
for that.
However, one language that does seem able to keep up to date is Perl.
So here’s my current password validation function:
def validate_password(password, hash) :
"hashes password using the algorithm and salt prefix from hash, and" \
" returns whether the result matches hash."
outhash = subprocess.check_output \
(
args = ("perl", "-e", "print crypt($ENV{\"PW\"}, $ENV{\"HASH\"});"),
env = {"PW" : password, "HASH" : hash},
text = True
).strip()
return \
outhash == hash
#end validate_password
What an...interesting commenting method. I would personally use
"""triple quotes""" to allow for multi-line comments ...
However, one language that does seem able to keep up to date is Perl.
So here’s my current password validation function:...
outhash = subprocess.check_output \
(
args = ("perl", "-e", "print crypt.... )
Lawrence D'Oliveiro <[email protected]d> writes:
However, one language that does seem able to keep up to date is Perl.
So here’s my current password validation function:...
outhash = subprocess.check_output \
(
args = ("perl", "-e", "print crypt.... )
Ugh! Better to re-implement the function in Python.
I think I will create my own wrapper using ctypes.
On Fri, 21 Jun 2024 03:40:55 -0000 (UTC), I wrote:
I think I will create my own wrapper using ctypes.
Done <https://gitlab.com/ldo/nixcrypt>.
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (0 / 16) |
| Uptime: | 168:28:33 |
| Calls: | 12,097 |
| Calls today: | 5 |
| Files: | 15,003 |
| Messages: | 6,517,823 |