misleading rounds param for sha521_crypt
Hi,
I do the following:
#!/usr/bin/env python3
import secrets
import passlib.hash
from pprint import pprint
SALT_LEN=8
crypter = passlib.hash.sha512_crypt(salt=secrets.token_hex(SALT_LEN), rounds=5000)
result = crypter.hash('test')
pprint(result)
pprint(crypter.verify('test', result))
and the result I got:
'$6$rounds=656000$wq48b6CZ8H/cPgDV$HRu3fPUwkfSK4JHXriKxwotNw/I/ul2Gq76mU5e7w0PSaxePwn77NK/GuuQvCaKmOeLMfDUbAGajQStVyPnMT.'
True
please note the fact that I specify rounds as 5000 and I'm getting rounds=656000 in hashed output. That wouldn't bother me as this is default value, however, when I omit rounds param I'm getting:
Traceback (most recent call last):
File "./generate_pass.py", line 9, in <module>
crypter = passlib.hash.sha512_crypt(salt=secrets.token_hex(SALT_LEN)) # , rounds=5000)
File "/venv/lib/python3.10/site-packages/passlib/handlers/sha2_crypt.py", line 281, in __init__
super(_SHA2_Common, self).__init__(**kwds)
File "/venv/lib/python3.10/site-packages/passlib/utils/handlers.py", line 1801, in __init__
raise TypeError("no rounds specified")
TypeError: no rounds specified
my questions:
- is it possible to generate hash with 5000 rounds? if yes - how?
- why rounds param is mandatory while it is ignored during hash generation?
Thanks in advance for Your help and Big Thanks for Your work on the library
Ser@fin