This repository has been archived by the owner on Mar 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplified device selection of yhsm.
- Loading branch information
1 parent
ef1b00d
commit 33b113f
Showing
6 changed files
with
69 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[nosetests] | ||
attr=!hsm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from passlib.context import CryptContext | ||
from passlib.registry import register_crypt_handler_path | ||
|
||
register_crypt_handler_path('yhsm_pbkdf2_sha1', 'yubiauth.yhsm') | ||
register_crypt_handler_path('yhsm_pbkdf2_sha256', 'yubiauth.yhsm') | ||
register_crypt_handler_path('yhsm_pbkdf2_sha512', 'yubiauth.yhsm') | ||
|
||
from nose.plugins.attrib import attr | ||
|
||
PASSWORDS = [ | ||
'foobar', | ||
'', | ||
'1234567890', | ||
'!"#%&/()=?', | ||
chr(150) + chr(200) + chr(255) | ||
] | ||
|
||
context = CryptContext( | ||
schemes=['yhsm_pbkdf2_sha1', 'yhsm_pbkdf2_sha256', 'yhsm_pbkdf2_sha512'], | ||
default='yhsm_pbkdf2_sha1', | ||
all__key_handle=1, | ||
all__rounds=10 | ||
) | ||
|
||
|
||
def _algorithm_test(scheme): | ||
for pwd in PASSWORDS: | ||
res = context.encrypt(pwd, scheme=scheme) | ||
assert context.identify(res) == scheme | ||
assert context.verify(pwd, res) | ||
assert res != context.encrypt(pwd, scheme=scheme) | ||
|
||
|
||
@attr(hsm=True) | ||
def test_yhsm_pbkdf2_sha1(): | ||
_algorithm_test('yhsm_pbkdf2_sha1') | ||
|
||
|
||
@attr(hsm=True) | ||
def test_yhsm_pbkdf2_sha256(): | ||
_algorithm_test('yhsm_pbkdf2_sha256') | ||
|
||
|
||
@attr(hsm=True) | ||
def test_yhsm_pbkdf2_sha512(): | ||
_algorithm_test('yhsm_pbkdf2_sha512') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters