From fe62a51c052dfa13b91b760188cd57e73971ddbf Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Fri, 14 Oct 2016 13:47:16 +0200 Subject: Command unlock user password for NK Storage Signed-off-by: Szczepan Zalega --- NitrokeyManager.cc | 24 ++++++++++++++++++++---- 1 file 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(); - 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(); + 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(); + p2.set_kind(PasswordKind::Admin); + strcpyT(p2.old_pin, admin_password); + ChangeAdminUserPin20Current::CommandTransaction::run(*device, p2); + auto p3 = get_payload(); + p3.set_kind(PasswordKind::Admin); + strcpyT(p3.user_new_password, new_user_password); + stick20::UnlockUserPassword::CommandTransaction::run(*device, p3); + break; + } + } } -- cgit v1.2.3