summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-07-20 12:36:10 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-01 13:54:56 +0200
commit9d41a8fe54a6acf2282f8c3bd653d2bcae729f20 (patch)
treeed995d430ff1fcb7b611a9ba41e55148dac7aecf
parent8d21114df0ee75e2129916acb38b212704ed78cf (diff)
downloadlibnitrokey-9d41a8fe54a6acf2282f8c3bd653d2bcae729f20.tar.gz
libnitrokey-9d41a8fe54a6acf2282f8c3bd653d2bcae729f20.tar.bz2
Working HOTP handling (passing RFC tests)
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r--build/test.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/build/test.py b/build/test.py
index 5117410..195894f 100644
--- a/build/test.py
+++ b/build/test.py
@@ -38,7 +38,7 @@ if __name__ == "__main__":
for i in range(3):
s.append(ffi.string(C.NK_get_hotp_slot_name(i)))
print(repr(s))
- print((s))
+ print(s)
s = []
for i in range(16):
@@ -57,10 +57,22 @@ if __name__ == "__main__":
# print((s))
# C.NK_totp_mark_time()
+ # C.NK_set_debug(True)
+
+
+ # https://tools.ietf.org/html/rfc4226#page-32
+ C.NK_write_hotp_slot(1, 'python_test', '12345678901234567890', 0, '123123123')
+ test_data = [
+ 755224, 287082, 359152, 969429, 338314, 254676, 287922, 162583, 399871, 520489,
+ ]
+ a = []
+ for code in test_data:
+ r = C.NK_get_hotp_code(1)
+ a.append((r, code == r))
+ print(a)
# test according to https://tools.ietf.org/html/rfc6238#appendix-B
C.NK_write_totp_slot(1, 'python_test', '12345678901234567890', 30, True, '123123123')
- C.NK_set_debug(True)
test_data = [
(59, 1, 94287082),
(1111111109, 0x00000000023523EC, 7081804),