aboutsummaryrefslogtreecommitdiff
path: root/NitrokeyManager.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 /NitrokeyManager.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 'NitrokeyManager.cc')
-rw-r--r--NitrokeyManager.cc25
1 files changed, 19 insertions, 6 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index ef0eb5e..69b2059 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -82,23 +82,29 @@ namespace nitrokey{
return resp.code;
}
- bool NitrokeyManager::erase_slot(uint8_t slot_number) {
+ bool NitrokeyManager::erase_slot(uint8_t slot_number, const char *temporary_password) {
auto p = get_payload<EraseSlot>();
p.slot_number = slot_number;
+
+ auto auth = get_payload<Authorize>();
+ strcpyT(auth.temporary_password, temporary_password);
+ auth.crc_to_authorize = EraseSlot::CommandTransaction::getCRC(p);
+ Authorize::CommandTransaction::run(*device, auth);
+
auto resp = EraseSlot::CommandTransaction::run(*device,p);
return true;
}
- bool NitrokeyManager::erase_hotp_slot(uint8_t slot_number) {
+ bool NitrokeyManager::erase_hotp_slot(uint8_t slot_number, const char *temporary_password) {
assert(is_valid_hotp_slot_number(slot_number));
slot_number = get_internal_slot_number_for_hotp(slot_number);
- return erase_slot(slot_number);
+ return erase_slot(slot_number, temporary_password);
}
- bool NitrokeyManager::erase_totp_slot(uint8_t slot_number) {
+ bool NitrokeyManager::erase_totp_slot(uint8_t slot_number, const char *temporary_password) {
assert(is_valid_totp_slot_number(slot_number));
slot_number = get_internal_slot_number_for_totp(slot_number);
- return erase_slot(slot_number);
+ return erase_slot(slot_number, temporary_password);
}
@@ -173,7 +179,7 @@ namespace nitrokey{
return (uint8_t *) strdup((const char *) resp.slot_name);
}
- bool NitrokeyManager::authorize(const char *pin, const char *temporary_password) {
+ bool NitrokeyManager::first_authenticate(const char *pin, const char *temporary_password) {
auto authreq = get_payload<FirstAuthenticate>();
assert(strlen(pin) < sizeof authreq.card_password);
@@ -294,4 +300,11 @@ namespace nitrokey{
ErasePasswordSafeSlot::CommandTransaction::run(*device, p);
}
+ void NitrokeyManager::user_authenticate(const char *user_password, const char *temporary_password) {
+ auto p = get_payload<UserAuthenticate>();
+ strcpyT(p.card_password, user_password);
+ strcpyT(p.temporary_password, temporary_password);
+ UserAuthenticate::CommandTransaction::run(*device, p);
+ }
+
} \ No newline at end of file