aboutsummaryrefslogtreecommitdiff
path: root/NitrokeyManager.cc
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-07-29 14:28:58 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-01 13:54:58 +0200
commit24ad4504648cd3918bb181b1d54a7c3441c02ae0 (patch)
tree6bf301c6535868d4ec5b25b41e3b73362e790a88 /NitrokeyManager.cc
parentfeeb433a5625fd869e3b02c3254867c63b42086d (diff)
downloadlibnitrokey-24ad4504648cd3918bb181b1d54a7c3441c02ae0.tar.gz
libnitrokey-24ad4504648cd3918bb181b1d54a7c3441c02ae0.tar.bz2
Handle changing admin/user password on NK Storage - NitrokeyManager
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'NitrokeyManager.cc')
-rw-r--r--NitrokeyManager.cc31
1 files changed, 27 insertions, 4 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index 79cd868..7f7a870 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -239,10 +239,33 @@ namespace nitrokey{
ChangeUserPin::CommandTransaction::run(*device, p);
}
void NitrokeyManager::change_admin_PIN(char *current_PIN, char *new_PIN) {
- auto p = get_payload<ChangeAdminPin>();
- strcpyT(p.old_pin, current_PIN);
- strcpyT(p.new_pin, new_PIN);
- ChangeAdminPin::CommandTransaction::run(*device, p);
+ switch (device->get_device_model()){
+ case DeviceModel::PRO:
+ {
+ auto p = get_payload<ChangeAdminPin>();
+ strcpyT(p.old_pin, current_PIN);
+ strcpyT(p.new_pin, new_PIN);
+ ChangeAdminPin::CommandTransaction::run(*device, p);
+ }
+ break;
+ //in Storage change admin pin is divided to two commands with 20 chars field len
+ case DeviceModel::STORAGE:
+ {
+ auto p = get_payload<ChangeAdminPin20Current>();
+ strcpyT(p.old_pin, current_PIN);
+ p.kind = 'A';
+ p.set_kind(PasswordKind::Admin);
+ ChangeAdminPin20Current::CommandTransaction::run(*device, p);
+
+ auto p2 = get_payload<ChangeAdminPin20New>();
+ strcpyT(p2.new_pin, new_PIN);
+ p2.kind = 'A';
+ p2.set_kind(PasswordKind::Admin);
+ ChangeAdminPin20New::CommandTransaction::run(*device, p2);
+ }
+ break;
+ }
+
}
void NitrokeyManager::enable_password_safe(const char *user_pin) {