diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2016-10-14 13:47:16 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2016-10-19 16:34:11 +0200 |
commit | fe62a51c052dfa13b91b760188cd57e73971ddbf (patch) | |
tree | 9b9f040481280b9be1b70434284bddd4a0a18a78 | |
parent | a8965c05ff8b69d6f0dc51e41655acf8b198869b (diff) | |
download | libnitrokey-fe62a51c052dfa13b91b760188cd57e73971ddbf.tar.gz libnitrokey-fe62a51c052dfa13b91b760188cd57e73971ddbf.tar.bz2 |
Command unlock user password for NK Storage
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r-- | NitrokeyManager.cc | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc index e5d912d..78b5d84 100644 --- a/NitrokeyManager.cc +++ b/NitrokeyManager.cc @@ -403,10 +403,26 @@ namespace nitrokey{ } void NitrokeyManager::unlock_user_password(const char *admin_password, const char *new_user_password) { - auto p = get_payload<UnlockUserPassword>(); - strcpyT(p.admin_password, admin_password); - strcpyT(p.user_new_password, new_user_password); - UnlockUserPassword::CommandTransaction::run(*device, p); + switch (device->get_device_model()){ + case DeviceModel::PRO: { + auto p = get_payload<stick10::UnlockUserPassword>(); + strcpyT(p.admin_password, admin_password); + strcpyT(p.user_new_password, new_user_password); + stick10::UnlockUserPassword::CommandTransaction::run(*device, p); + break; + } + case DeviceModel::STORAGE : { + auto p2 = get_payload<ChangeAdminUserPin20Current>(); + p2.set_kind(PasswordKind::Admin); + strcpyT(p2.old_pin, admin_password); + ChangeAdminUserPin20Current::CommandTransaction::run(*device, p2); + auto p3 = get_payload<stick20::UnlockUserPassword>(); + p3.set_kind(PasswordKind::Admin); + strcpyT(p3.user_new_password, new_user_password); + stick20::UnlockUserPassword::CommandTransaction::run(*device, p3); + break; + } + } } |