aboutsummaryrefslogtreecommitdiff
path: root/NitrokeyManager.cc
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-07-25 17:38:15 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-01 13:54:57 +0200
commit8f4fb5d6320241a27d4d8c93d819daba40c58867 (patch)
tree04d4aa7565550516756cee7687c93796892be73b /NitrokeyManager.cc
parent7c4012b7074252d8a5cc3b462705e171112a85bf (diff)
downloadlibnitrokey-8f4fb5d6320241a27d4d8c93d819daba40c58867.tar.gz
libnitrokey-8f4fb5d6320241a27d4d8c93d819daba40c58867.tar.bz2
Handle changing user and admin PINs
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'NitrokeyManager.cc')
-rw-r--r--NitrokeyManager.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index 2a0033f..2b46927 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -176,7 +176,7 @@ namespace nitrokey{
bool NitrokeyManager::authorize(const char *pin, const char *temporary_password) {
auto authreq = get_payload<FirstAuthenticate>();
- assert(strlen(pin) < sizeof authreq.card_password); //160 bits
+ assert(strlen(pin) < sizeof authreq.card_password);
assert(strlen(temporary_password) < sizeof authreq.temporary_password);
strcpyT(authreq.card_password, pin);
@@ -200,5 +200,18 @@ namespace nitrokey{
return false;
}
+ void NitrokeyManager::change_user_PIN(char *current_PIN, char *new_PIN) {
+ auto p = get_payload<ChangeUserPin>();
+ strcpyT(p.old_pin, current_PIN);
+ strcpyT(p.new_pin, new_PIN);
+ 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);
+ }
+
} \ No newline at end of file