Skip to content

Commit 31a3fb4

Browse files
committed
use PBKDF2 implementation from Python's hashlib, if available
see issue2550982
1 parent 28977cc commit 31a3fb4

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ v2.7.2 is required to run newer releases of Roundup.
1616
Features:
1717

1818
- issue2550901: add search page to jinja2 template (Christof Meerwald)
19+
- issue2550982: use PBKDF2 in Python's hashlib, if available (Python
20+
2.7.8+), to improve performance over bundled pure Python
21+
version. Note that acceleration via m2crypto is no longer supported
22+
(Christof Meerwald)
1923

2024
Fixed:
2125

roundup/password.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@ def h64decode(data):
7373
return b64decode(data + b"=", b"./")
7474

7575
try:
76-
from M2Crypto.EVP import pbkdf2 as _pbkdf2
76+
from hashlib import pbkdf2_hmac
77+
def _pbkdf2(password, salt, rounds, keylen):
78+
return pbkdf2_hmac('sha1', password, salt, rounds, keylen)
7779
except ImportError:
78-
#no m2crypto - make our own pbkdf2 function
80+
#no hashlib.pbkdf2_hmac - make our own pbkdf2 function
7981
from struct import pack
8082
from hmac import HMAC
8183

@@ -119,7 +121,7 @@ def pbkdf2(password, salt, rounds, keylen):
119121
:param rounds: number of rounds to use to generate key
120122
:arg keylen: number of bytes to generate
121123
122-
If M2Crypto is present, uses it's implementation as backend.
124+
If hashlib supports pbkdf2, uses it's implementation as backend.
123125
124126
:returns:
125127
raw bytes of generated key

0 commit comments

Comments
 (0)