Mercurial > p > roundup > code
diff roundup/password.py @ 5483:3d0f71775e42
use PBKDF2 implementation from Python's hashlib, if available
see issue2550982
| author | Christof Meerwald <cmeerw@cmeerw.org> |
|---|---|
| date | Thu, 02 Aug 2018 07:19:23 +0100 |
| parents | fbbcbfc6dad0 |
| children | 52cb53eedf77 |
line wrap: on
line diff
--- a/roundup/password.py Wed Aug 01 22:54:10 2018 +0100 +++ b/roundup/password.py Thu Aug 02 07:19:23 2018 +0100 @@ -73,9 +73,11 @@ return b64decode(data + b"=", b"./") try: - from M2Crypto.EVP import pbkdf2 as _pbkdf2 + from hashlib import pbkdf2_hmac + def _pbkdf2(password, salt, rounds, keylen): + return pbkdf2_hmac('sha1', password, salt, rounds, keylen) except ImportError: - #no m2crypto - make our own pbkdf2 function + #no hashlib.pbkdf2_hmac - make our own pbkdf2 function from struct import pack from hmac import HMAC @@ -119,7 +121,7 @@ :param rounds: number of rounds to use to generate key :arg keylen: number of bytes to generate - If M2Crypto is present, uses it's implementation as backend. + If hashlib supports pbkdf2, uses it's implementation as backend. :returns: raw bytes of generated key
