summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-08-05 09:55:06 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-05 10:19:25 +0200
commitbc5261c18a4608806dcb866afb73f7a979e2e90f (patch)
tree77a71206566c9217f4cba40963ba8c6524451cbc
parent7c1c040bc57dcfd4ef8abdb481ef7b3df2b116b6 (diff)
downloadlibnitrokey-bc5261c18a4608806dcb866afb73f7a979e2e90f.tar.gz
libnitrokey-bc5261c18a4608806dcb866afb73f7a979e2e90f.tar.bz2
Allow user to choose new user PIN when unlocking
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r--NK_C_API.cc4
-rw-r--r--NK_C_API.h2
-rw-r--r--NitrokeyManager.cc3
-rw-r--r--include/NitrokeyManager.h2
-rw-r--r--include/stick10_commands.h3
5 files changed, 8 insertions, 6 deletions
diff --git a/NK_C_API.cc b/NK_C_API.cc
index 2b3b5ea..049e200 100644
--- a/NK_C_API.cc
+++ b/NK_C_API.cc
@@ -123,10 +123,10 @@ extern int NK_build_aes_key(const char* admin_password){
});
}
-extern int NK_unlock_user_password(const char* admin_password){
+extern int NK_unlock_user_password(const char *admin_password, const char *new_user_password) {
auto m = NitrokeyManager::instance();
return get_without_result( [&](){
- return m->unlock_user_password(admin_password);
+ m->unlock_user_password(admin_password, new_user_password);
});
}
diff --git a/NK_C_API.h b/NK_C_API.h
index 5554426..7610d29 100644
--- a/NK_C_API.h
+++ b/NK_C_API.h
@@ -81,7 +81,7 @@ extern int NK_build_aes_key(const char* admin_password);
* @param admin_password char[20](Pro) current administrator PIN
* @return command processing error code
*/
-extern int NK_unlock_user_password(const char* admin_password);
+extern int NK_unlock_user_password(const char *admin_password, const char *new_user_password);
/**
* Write general config to the device
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index f7b3492..b61b2b2 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -372,9 +372,10 @@ namespace nitrokey{
FactoryReset::CommandTransaction::run(*device, p);
}
- void NitrokeyManager::unlock_user_password(const char *admin_password) {
+ 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);
}
diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h
index 0a27bd8..5f89614 100644
--- a/include/NitrokeyManager.h
+++ b/include/NitrokeyManager.h
@@ -70,7 +70,7 @@ namespace nitrokey {
void build_aes_key(const char *admin_password);
- void unlock_user_password(const char *admin_password);
+ void unlock_user_password(const char *admin_password, const char *new_user_password);
void write_config(bool numlock, bool capslock, bool scrolllock, bool enable_user_password,
bool delete_user_password, const char *admin_temporary_password);
diff --git a/include/stick10_commands.h b/include/stick10_commands.h
index f275993..051547e 100644
--- a/include/stick10_commands.h
+++ b/include/stick10_commands.h
@@ -686,7 +686,8 @@ class UserAuthorize : Command<CommandID::USER_AUTHORIZE> {
class UnlockUserPassword : Command<CommandID::UNLOCK_USER_PASSWORD> {
public:
struct CommandPayload {
- uint8_t admin_password[20];
+ uint8_t admin_password[25];
+ uint8_t user_new_password[25];
std::string dissect() const {
std::stringstream ss;
ss << " admin_password:\t" << admin_password<< std::endl;