summaryrefslogtreecommitdiff
path: root/admin
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2013-01-23 14:06:15 -0500
committerEli Collins <elic@assurancetechnologies.com>2013-01-23 14:06:15 -0500
commit951ac1222a827846d3e598fa39f1d1af94022ec4 (patch)
treecc19f634b784edf76bca6c51579a88765300836f /admin
parent0c181eb28b5d7924a54ae2ba418c9a92946d3e0b (diff)
downloadpasslib-951ac1222a827846d3e598fa39f1d1af94022ec4.tar.gz
pbkdf2() sped up ~20% by precomputing intermediate hmac hashes
* also added get_hash_info(), get_keyed_prf() helpers (which still need their own docs & unittests) * a few more tweaks to simplify code paths in pbkdf2.py
Diffstat (limited to 'admin')
-rw-r--r--admin/benchmarks.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/admin/benchmarks.py b/admin/benchmarks.py
index 4687f37..94f8610 100644
--- a/admin/benchmarks.py
+++ b/admin/benchmarks.py
@@ -6,6 +6,7 @@ parsing was being sped up. it could definitely be improved.
#=============================================================================
# init script env
#=============================================================================
+from binascii import hexlify
import re
import os, sys
root = os.path.join(os.path.dirname(__file__), os.path.pardir)
@@ -251,14 +252,20 @@ def test_phpass():
# crypto utils
#=============================================================================
@benchmark.constructor()
-def test_pbkdf2():
-# from passlib.hash import pbkdf2_sha1
- from passlib.hash import pbkdf2_sha256 as hash
+def test_pbkdf2_sha1():
+ from passlib.utils.pbkdf2 import pbkdf2
def helper():
-# hash.encrypt("password", salt="salt", rounds=10000)
- result = pbkdf2_sha1.encrypt("password", salt="salt", rounds=10000)
- assert result == '$pbkdf2-sha256$10240$c2FsdA$FUGp71zmshcv1IwX1DV3ADWDyP66H/ANJZwmoGuF7FA'
- yield helper
+ result = hexlify(pbkdf2("abracadabra", "open sesame", 10240, 20, "hmac-sha1"))
+ assert result == 'e45ce658e79b16107a418ad4634836f5f0601ad1', result
+ return helper
+
+@benchmark.constructor()
+def test_pbkdf2_sha256():
+ from passlib.utils.pbkdf2 import pbkdf2
+ def helper():
+ result = hexlify(pbkdf2("abracadabra", "open sesame", 10240, 32, "hmac-sha256"))
+ assert result == 'fadef97054306c93c55213cd57111d6c0791735dcdde8ac32f9f934b49c5af1e', result
+ return helper
#=============================================================================
# main