diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2020-04-02 15:19:00 +0200 |
---|---|---|
committer | Robin Krahl <robin.krahl@ireas.org> | 2020-04-02 15:20:59 +0200 |
commit | fedf828e394938fb6f84407b4de7412a3fb6ec40 (patch) | |
tree | ff101e273e82e16945576b424615c6a21031c0ee /unittest | |
parent | 02f19713c155457e8cc7d80d581bdac35cb1716d (diff) | |
download | libnitrokey-fedf828e394938fb6f84407b4de7412a3fb6ec40.tar.gz libnitrokey-fedf828e394938fb6f84407b4de7412a3fb6ec40.tar.bz2 |
Return serial number as uint32_t from C API
This patch adds the function NK_device_serial_number_as_u32 to the C
API. It is similar to NK_device_serial_number but returns the raw
unsigned integer instead of a formatted string. This patch also adds a
simple test case that ensures that the number is not zero.
Fixes #172.
Diffstat (limited to 'unittest')
-rw-r--r-- | unittest/test_pro.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/unittest/test_pro.py b/unittest/test_pro.py index 99d7b1f..d25a50e 100644 --- a/unittest/test_pro.py +++ b/unittest/test_pro.py @@ -704,6 +704,13 @@ def test_get_serial_number(C): print(('Serial number of the device: ', sn)) +@pytest.mark.status +def test_get_serial_number_as_u32(C): + sn = C.NK_device_serial_number_as_u32() + assert sn > 0 + print(('Serial number of the device (u32): ', sn)) + + @pytest.mark.otp @pytest.mark.parametrize("secret", ['000001', '00'*10+'ff', '00'*19+'ff', '000102', '00'*29+'ff', '00'*39+'ff', '002EF43F51AFA97BA2B46418768123C9E1809A5B' ]) @@ -1038,4 +1045,4 @@ def test_OTP_all_rw(C): this_loop_codes.append(('H', i, code)) all_codes.append(this_loop_codes) from pprint import pprint - pprint(all_codes)
\ No newline at end of file + pprint(all_codes) |