aboutsummaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-07-20 12:26:53 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-01 13:54:56 +0200
commit8d21114df0ee75e2129916acb38b212704ed78cf (patch)
tree625eced9f399e5028cd51958e5ff38b90aa9be67 /build
parent02a46831a552d443adfbd3c61542cf6925675349 (diff)
downloadlibnitrokey-8d21114df0ee75e2129916acb38b212704ed78cf.tar.gz
libnitrokey-8d21114df0ee75e2129916acb38b212704ed78cf.tar.bz2
Working TOTP handling (passing RFC tests)
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'build')
-rw-r--r--build/test.py33
1 files changed, 24 insertions, 9 deletions
diff --git a/build/test.py b/build/test.py
index 9d967ca..5117410 100644
--- a/build/test.py
+++ b/build/test.py
@@ -46,15 +46,30 @@ if __name__ == "__main__":
for i in range(3):
s.append(C.NK_get_hotp_code(i))
print(repr(s))
- print((s))
+ print(s)
# C.NK_set_debug(True)
- s = []
- C.NK_write_hotp_slot(1, 'python_test', '12345678901234567890', 0, '123123123')
- C.NK_set_debug(False)
- for i in range(3):
- s.append(C.NK_get_hotp_code(1))
- print((s))
+ # s = []
+ # C.NK_write_hotp_slot(1, 'python_test', '12345678901234567890', 0, '123123123')
+ # C.NK_set_debug(False)
+ # for i in range(3):
+ # s.append(C.NK_get_hotp_code(1))
+ # print((s))
+
+ # C.NK_totp_mark_time()
+
+ # 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)
- C.NK_write_totp_slot(1, 'python_test', '12345678901234567890', 30, '123123123')
- print ( C.NK_get_totp_code(1, 59, 0, 30) ) \ No newline at end of file
+ test_data = [
+ (59, 1, 94287082),
+ (1111111109, 0x00000000023523EC, 7081804),
+ (1111111111, 0x00000000023523ED, 14050471),
+ (1234567890, 0x000000000273EF07, 89005924),
+ ]
+ a = []
+ for t, T, code in test_data:
+ C.NK_totp_set_time(t)
+ r = C.NK_get_totp_code(1, T, 0, 30) # FIXME T is not changing the outcome
+ a.append((r, code == r))
+ print(a)