From 3632e8a32d47950102bc077fd32f9c88316370e9 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Sat, 10 Sep 2016 10:50:59 +0200 Subject: Assume secret is coded in hex for OTP slot write #31 Signed-off-by: Szczepan Zalega --- unittest/test_bindings.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'unittest') diff --git a/unittest/test_bindings.py b/unittest/test_bindings.py index eeda247..377203e 100644 --- a/unittest/test_bindings.py +++ b/unittest/test_bindings.py @@ -5,8 +5,15 @@ from enum import Enum ffi = cffi.FFI() gs = ffi.string -RFC_SECRET = '12345678901234567890' +def to_hex(s): + return "".join("{:02x}".format(ord(c)) for c in s) + + +RFC_SECRET_HR = '12345678901234567890' +RFC_SECRET = to_hex(RFC_SECRET_HR) #'12345678901234567890' + +# print( repr((RFC_SECRET, RFC_SECRET_, len(RFC_SECRET))) ) class DefaultPasswords(Enum): ADMIN = '12345678' @@ -214,7 +221,7 @@ def test_invalid_slot(C): invalid_slot = 255 assert C.NK_erase_totp_slot(invalid_slot, 'some password') == LibraryErrors.INVALID_SLOT assert C.NK_write_hotp_slot(invalid_slot, 'long_test', RFC_SECRET, 0, False, False, False, "", - 'aaa') == LibraryErrors.INVALID_SLOT + 'aaa') == LibraryErrors.INVALID_SLOT assert C.NK_get_hotp_code_PIN(invalid_slot, 'some password') == 0 assert C.NK_get_last_command_status() == LibraryErrors.INVALID_SLOT assert C.NK_erase_password_safe_slot(invalid_slot) == LibraryErrors.INVALID_SLOT -- cgit v1.2.3