aboutsummaryrefslogtreecommitdiff
path: root/NK_C_API.cc
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-07-26 23:35:24 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-01 13:54:57 +0200
commitf5b5339a0cd272b3be33013f01e14f5bcc6e5aa8 (patch)
tree78d21a5736b96c859f02ca51c8c9e87bd3e696b8 /NK_C_API.cc
parent128a98b0f0a4eca879dbf9d6562ab744a36510e8 (diff)
downloadlibnitrokey-f5b5339a0cd272b3be33013f01e14f5bcc6e5aa8.tar.gz
libnitrokey-f5b5339a0cd272b3be33013f01e14f5bcc6e5aa8.tar.bz2
Erasing slot - initial version with some authorization issues
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'NK_C_API.cc')
-rw-r--r--NK_C_API.cc25
1 files changed, 20 insertions, 5 deletions
diff --git a/NK_C_API.cc b/NK_C_API.cc
index 094a7e3..db96c52 100644
--- a/NK_C_API.cc
+++ b/NK_C_API.cc
@@ -50,7 +50,7 @@ extern int NK_login(const char *admin_pin, const char *temporary_password) {
auto m = NitrokeyManager::instance();
try {
m->connect();
- m->authorize(admin_pin, temporary_password);
+ m->first_authenticate(admin_pin, temporary_password);
}
catch (CommandFailedException & commandFailedException){
NK_last_command_status = commandFailedException.last_command_status;
@@ -71,6 +71,21 @@ extern int NK_logout() {
return 0;
}
+extern int NK_first_authenticate(const char* admin_password, const char* admin_temporary_password){
+ auto m = NitrokeyManager::instance();
+ return get_without_result( [&](){
+ return m->first_authenticate(admin_password, admin_temporary_password);
+ });
+}
+
+
+extern int NK_user_authenticate(const char* user_password, const char* user_temporary_password){
+ auto m = NitrokeyManager::instance();
+ return get_without_result( [&](){
+ return m->user_authenticate(user_password, user_temporary_password);
+ });
+}
+
extern const char * NK_status() {
auto m = NitrokeyManager::instance();
try {
@@ -106,10 +121,10 @@ extern uint32_t NK_get_totp_code(uint8_t slot_number, uint64_t challenge, uint64
return 0;
}
-extern int NK_erase_hotp_slot(uint8_t slot_number) {
+extern int NK_erase_hotp_slot(uint8_t slot_number, const char *temporary_password) {
auto m = NitrokeyManager::instance();
try {
- m->erase_hotp_slot(slot_number);
+ m->erase_hotp_slot(slot_number, temporary_password);
}
catch (CommandFailedException & commandFailedException){
NK_last_command_status = commandFailedException.last_command_status;
@@ -118,10 +133,10 @@ extern int NK_erase_hotp_slot(uint8_t slot_number) {
return 0;
}
-extern int NK_erase_totp_slot(uint8_t slot_number) {
+extern int NK_erase_totp_slot(uint8_t slot_number, const char *temporary_password) {
auto m = NitrokeyManager::instance();
try {
- m->erase_totp_slot(slot_number);
+ m->erase_totp_slot(slot_number, temporary_password);
}
catch (CommandFailedException & commandFailedException){
NK_last_command_status = commandFailedException.last_command_status;