From 7b598fe89d604ef91efd4f71253ffb9ab0aae7c5 Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Wed, 10 Feb 2016 14:27:53 -0500 Subject: relocated many of the crypto routes inside passlib.utils, and moved them to a separate passlib.crypto subpackage. along with this move, made a few api cleanups: * unified all code that's looking up hashes to use new passlib.crypto.lookup_hash() wrapper, which takes care of hash name normalization, loading fallback implementations, and alg metadata inspection, all hidden behind a memoized function. * deprecated pbkdf2() in favor of pbkdf2_hmac() -- only real use, and new signature matches stdlib function. additionally, this version is a bit faster, due to some assumptions that can be made due to the PRF always being HMAC based. * added compile_hmac() helper which does an even more efficient job of pre-compiling a keyed HMAC function; this helped speed up pbkdf2 a bit more. --- admin/benchmarks.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'admin') diff --git a/admin/benchmarks.py b/admin/benchmarks.py index 1a01951..3a980c0 100644 --- a/admin/benchmarks.py +++ b/admin/benchmarks.py @@ -283,17 +283,17 @@ def test_sha1_crypt(): #============================================================================= @benchmark.constructor() def test_pbkdf2_sha1(): - from passlib.utils.pbkdf2 import pbkdf2 + from passlib.crypto.digest import pbkdf2_hmac def helper(): - result = hexlify(pbkdf2("abracadabra", "open sesame", 10240, 20, "hmac-sha1")) + result = hexlify(pbkdf2_hmac("sha1", "abracadabra", "open sesame", 10240, 20)) assert result == 'e45ce658e79b16107a418ad4634836f5f0601ad1', result return helper @benchmark.constructor() def test_pbkdf2_sha256(): - from passlib.utils.pbkdf2 import pbkdf2 + from passlib.crypto.digest import pbkdf2_hmac def helper(): - result = hexlify(pbkdf2("abracadabra", "open sesame", 10240, 32, "hmac-sha256")) + result = hexlify(pbkdf2_hmac("sha256", "abracadabra", "open sesame", 10240, 32)) assert result == 'fadef97054306c93c55213cd57111d6c0791735dcdde8ac32f9f934b49c5af1e', result return helper -- cgit v1.2.1