diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2016-07-26 10:59:24 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2016-08-01 13:54:57 +0200 |
commit | 8a938be4ffa97490d89206cc1fd079a057cfc65c (patch) | |
tree | 5f2794b8858551eb8cd9f1574d1682567674a04e /NK_C_API.cc | |
parent | b37e5990aa409689e5d6162776583616ac03e0ac (diff) | |
download | libnitrokey-8a938be4ffa97490d89206cc1fd079a057cfc65c.tar.gz libnitrokey-8a938be4ffa97490d89206cc1fd079a057cfc65c.tar.bz2 |
Manage retry counts of user and admin passwords
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'NK_C_API.cc')
-rw-r--r-- | NK_C_API.cc | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/NK_C_API.cc b/NK_C_API.cc index 77bd181..7de5bbd 100644 --- a/NK_C_API.cc +++ b/NK_C_API.cc @@ -5,6 +5,17 @@ using namespace nitrokey; static uint8_t NK_last_command_status = 0; +template <typename T> +auto get_with_result(T func){ + try { + return func(); + } + catch (CommandFailedException & commandFailedException){ + NK_last_command_status = commandFailedException.last_command_status; + return commandFailedException.last_command_status; + } +} + extern "C" { extern uint8_t NK_get_last_command_status(){ @@ -211,7 +222,7 @@ extern int NK_enable_password_safe(const char *user_pin){ extern int NK_get_password_safe_slot_status(){ auto m = NitrokeyManager::instance(); try { - m->get_password_safe_slot_status(); + m->get_password_safe_slot_status(); //TODO FIXME } catch (CommandFailedException & commandFailedException){ NK_last_command_status = commandFailedException.last_command_status; @@ -220,4 +231,20 @@ extern int NK_get_password_safe_slot_status(){ return 0; } -}
\ No newline at end of file +extern uint8_t NK_get_user_retry_count(){ + auto m = NitrokeyManager::instance(); + return get_with_result([&](){ + return m->get_user_retry_count(); + }); +} + +extern uint8_t NK_get_admin_retry_count(){ + auto m = NitrokeyManager::instance(); + return get_with_result([&](){ + return m->get_admin_retry_count(); + }); +} + + +} + |