From c34196ea22e61c31fa83c22a3b73c19ba04a30bf Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Tue, 26 Jul 2016 17:20:21 +0200 Subject: Prepare setting password safe slots Signed-off-by: Szczepan Zalega --- NitrokeyManager.cc | 2 +- include/stick10_commands.h | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc index e0f5fa3..d453f7b 100644 --- a/NitrokeyManager.cc +++ b/NitrokeyManager.cc @@ -215,7 +215,7 @@ namespace nitrokey{ void NitrokeyManager::enable_password_safe(const char *user_pin) { auto p = get_payload(); - strcpyT(p.password, user_pin); + strcpyT(p.user_password, user_pin); EnablePasswordSafe::CommandTransaction::run(*device, p); } diff --git a/include/stick10_commands.h b/include/stick10_commands.h index 92bddd5..c3b0a37 100644 --- a/include/stick10_commands.h +++ b/include/stick10_commands.h @@ -462,6 +462,13 @@ class SetPasswordSafeSlotData : Command { uint8_t slot_password[PWS_PASSWORD_LENGTH]; bool isValid() const { return !(slot_number & 0xF0); } + std::string dissect() const { + std::stringstream ss; + ss << " slot_number\t" << (int)slot_number << std::endl; + ss << " slot_name\t" << (char*)slot_name << std::endl; + ss << " slot_password\t" << (char*)slot_password << std::endl; + return ss.str(); + } } __packed; typedef Transaction @@ -475,6 +482,12 @@ class SetPasswordSafeSlotData2 : Command { uint8_t slot_name[PWS_SLOTNAME_LENGTH]; bool isValid() const { return !(slot_number & 0xF0); } + std::string dissect() const { + std::stringstream ss; + ss << " slot_number\t" << (int)slot_number << std::endl; + ss << " slot_name\t" << (char*)slot_name << std::endl; + return ss.str(); + } } __packed; typedef Transaction @@ -487,6 +500,12 @@ class ErasePasswordSafeSlot : Command { uint8_t slot_number; bool isValid() const { return !(slot_number & 0xF0); } + std::string dissect() const { + std::stringstream ss; + ss << " slot_number\t" << (int)slot_number << std::endl; + return ss.str(); + } + } __packed; typedef Transaction @@ -496,12 +515,12 @@ class ErasePasswordSafeSlot : Command { class EnablePasswordSafe : Command { public: struct CommandPayload { - uint8_t password[30]; + uint8_t user_password[30]; bool isValid() const { return true; } std::string dissect() const { std::stringstream ss; - ss << " password\t" << password << std::endl; + ss << " user_password\t" << (char*) user_password << std::endl; return ss.str(); } } __packed; -- cgit v1.2.1