diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2016-07-27 08:40:57 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2016-08-01 13:54:57 +0200 |
commit | ae8f2596895ba27539409b2399d985b2c613e2d7 (patch) | |
tree | 2ab661678c4bf838a79b0b4a4acd4942e8b34f36 | |
parent | 37d833828746b2437479123866d5c54ae78e2b14 (diff) | |
download | libnitrokey-ae8f2596895ba27539409b2399d985b2c613e2d7.tar.gz libnitrokey-ae8f2596895ba27539409b2399d985b2c613e2d7.tar.bz2 |
Getting password safe data does not need admin temp
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r-- | NK_C_API.cc | 12 | ||||
-rw-r--r-- | NK_C_API.h | 6 | ||||
-rw-r--r-- | NitrokeyManager.cc | 6 | ||||
-rw-r--r-- | include/NitrokeyManager.h | 6 | ||||
-rw-r--r-- | unittest/test_bindings.py | 12 |
5 files changed, 21 insertions, 21 deletions
diff --git a/NK_C_API.cc b/NK_C_API.cc index 6565b7c..441acb9 100644 --- a/NK_C_API.cc +++ b/NK_C_API.cc @@ -311,23 +311,23 @@ extern int NK_lock_device(){ }); } -extern const char *NK_get_password_safe_slot_name(uint8_t slot_number, const char *temporary_password) { +extern const char *NK_get_password_safe_slot_name(uint8_t slot_number) { auto m = NitrokeyManager::instance(); return get_with_string_result([&](){ - return m->get_password_safe_slot_name(slot_number, temporary_password); + return m->get_password_safe_slot_name(slot_number); }); } -extern const char *NK_get_password_safe_slot_login(uint8_t slot_number, const char *temporary_password) { +extern const char *NK_get_password_safe_slot_login(uint8_t slot_number) { auto m = NitrokeyManager::instance(); return get_with_string_result([&](){ - return m->get_password_safe_slot_login(slot_number, temporary_password); + return m->get_password_safe_slot_login(slot_number); }); } -extern const char *NK_get_password_safe_slot_password(uint8_t slot_number, const char *temporary_password) { +extern const char *NK_get_password_safe_slot_password(uint8_t slot_number) { auto m = NitrokeyManager::instance(); return get_with_string_result([&](){ - return m->get_password_safe_slot_password(slot_number, temporary_password); + return m->get_password_safe_slot_password(slot_number); }); } extern int NK_write_password_safe_slot(uint8_t slot_number, const char *slot_name, const char *slot_login, @@ -39,9 +39,9 @@ extern uint8_t NK_get_admin_retry_count(); //password safe extern int NK_enable_password_safe(const char *user_pin); extern uint8_t * NK_get_password_safe_slot_status(); -extern const char *NK_get_password_safe_slot_name(uint8_t slot_number, const char *temporary_password); -extern const char *NK_get_password_safe_slot_login(uint8_t slot_number, const char *temporary_password); -extern const char *NK_get_password_safe_slot_password(uint8_t slot_number, const char *temporary_password); +extern const char *NK_get_password_safe_slot_name(uint8_t slot_number); +extern const char *NK_get_password_safe_slot_login(uint8_t slot_number); +extern const char *NK_get_password_safe_slot_password(uint8_t slot_number); extern int NK_write_password_safe_slot(uint8_t slot_number, const char *slot_name, const char *slot_login, const char *slot_password); extern int NK_erase_password_safe_slot(uint8_t slot_number); } diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc index 4446d38..31436e5 100644 --- a/NitrokeyManager.cc +++ b/NitrokeyManager.cc @@ -246,7 +246,7 @@ namespace nitrokey{ LockDevice::CommandTransaction::run(*device); } - const char *NitrokeyManager::get_password_safe_slot_name(uint8_t slot_number, const char *temporary_password) { + const char *NitrokeyManager::get_password_safe_slot_name(uint8_t slot_number) { assert (is_valid_password_safe_slot_number(slot_number)); auto p = get_payload<GetPasswordSafeSlotName>(); p.slot_number = slot_number; @@ -256,7 +256,7 @@ namespace nitrokey{ bool NitrokeyManager::is_valid_password_safe_slot_number(uint8_t slot_number) const { return slot_number < 16; } - const char *NitrokeyManager::get_password_safe_slot_login(uint8_t slot_number, const char *temporary_password) { + const char *NitrokeyManager::get_password_safe_slot_login(uint8_t slot_number) { assert (is_valid_password_safe_slot_number(slot_number)); auto p = get_payload<GetPasswordSafeSlotLogin>(); p.slot_number = slot_number; @@ -264,7 +264,7 @@ namespace nitrokey{ return strdup((const char *) response.slot_login); } - const char *NitrokeyManager::get_password_safe_slot_password(uint8_t slot_number, const char *temporary_password) { + const char *NitrokeyManager::get_password_safe_slot_password(uint8_t slot_number) { assert (is_valid_password_safe_slot_number(slot_number)); auto p = get_payload<GetPasswordSafeSlotPassword>(); p.slot_number = slot_number; diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h index 5bd253d..47aca83 100644 --- a/include/NitrokeyManager.h +++ b/include/NitrokeyManager.h @@ -49,9 +49,9 @@ namespace nitrokey { void lock_device(); - const char *get_password_safe_slot_name(uint8_t slot_number, const char *temporary_password); - const char *get_password_safe_slot_password(uint8_t slot_number, const char *temporary_password); - const char *get_password_safe_slot_login(uint8_t slot_number, const char *temporary_password); + const char *get_password_safe_slot_name(uint8_t slot_number); + const char *get_password_safe_slot_password(uint8_t slot_number); + const char *get_password_safe_slot_login(uint8_t slot_number); void write_password_safe_slot(uint8_t slot_number, const char *slot_name, const char *slot_login, diff --git a/unittest/test_bindings.py b/unittest/test_bindings.py index 7632a5f..f3c3ee7 100644 --- a/unittest/test_bindings.py +++ b/unittest/test_bindings.py @@ -68,20 +68,20 @@ def test_get_password_safe_slot_name(C): assert C.NK_enable_password_safe(DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK assert C.NK_write_password_safe_slot(0, 'slotname1', 'login1', 'pass1') == DeviceErrorCode.STATUS_OK assert C.NK_lock_device() == DeviceErrorCode.STATUS_OK - assert gs(C.NK_get_password_safe_slot_name(0, DefaultPasswords.USER_TEMP)) == '' + assert gs(C.NK_get_password_safe_slot_name(0)) == '' assert C.NK_get_last_command_status() == DeviceErrorCode.STATUS_NOT_AUTHORIZED assert C.NK_enable_password_safe(DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK - assert gs(C.NK_get_password_safe_slot_name(0, DefaultPasswords.ADMIN_TEMP)) == 'slotname1' + assert gs(C.NK_get_password_safe_slot_name(0)) == 'slotname1' assert C.NK_get_last_command_status() == DeviceErrorCode.STATUS_OK def test_get_password_safe_slot_login_password(C): assert C.NK_enable_password_safe(DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK - slot_login = C.NK_get_password_safe_slot_login(0, DefaultPasswords.ADMIN_TEMP) + slot_login = C.NK_get_password_safe_slot_login(0) assert C.NK_get_last_command_status() == DeviceErrorCode.STATUS_OK assert gs(slot_login) == 'login1' - slot_password = gs(C.NK_get_password_safe_slot_password(0, DefaultPasswords.ADMIN_TEMP)) + slot_password = gs(C.NK_get_password_safe_slot_password(0)) assert C.NK_get_last_command_status() == DeviceErrorCode.STATUS_OK assert slot_password == 'pass1' @@ -89,7 +89,7 @@ def test_get_password_safe_slot_login_password(C): def test_erase_password_safe_slot(C): assert C.NK_enable_password_safe(DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK assert C.NK_erase_password_safe_slot(0) == DeviceErrorCode.STATUS_OK - assert gs(C.NK_get_password_safe_slot_name(0, DefaultPasswords.ADMIN_TEMP)) == '' + assert gs(C.NK_get_password_safe_slot_name(0)) == '' assert C.NK_get_last_command_status() == DeviceErrorCode.STATUS_OK # TODO CHECK shouldn't this be DeviceErrorCode.NOT_PROGRAMMED ? @@ -164,7 +164,7 @@ def test_TOTP_RFC(C): def test_get_slot_names(C): C.NK_set_debug(True) - # assert C.NK_erase_totp_slot(0, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK + assert C.NK_erase_totp_slot(0, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK # erasing slot invalidates temporary password, so requesting authentication # assert C.NK_first_authenticate(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK # assert C.NK_erase_hotp_slot(0, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK |