From ae8f2596895ba27539409b2399d985b2c613e2d7 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Wed, 27 Jul 2016 08:40:57 +0200 Subject: Getting password safe data does not need admin temp Signed-off-by: Szczepan Zalega --- NK_C_API.cc | 12 ++++++------ NK_C_API.h | 6 +++--- NitrokeyManager.cc | 6 +++--- include/NitrokeyManager.h | 6 +++--- 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, diff --git a/NK_C_API.h b/NK_C_API.h index 9dc1bce..29505fd 100644 --- a/NK_C_API.h +++ b/NK_C_API.h @@ -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(); 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(); 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(); 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 -- cgit v1.2.3