From 8c5b24092faf90672523e60e6eee12a83539ce11 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Wed, 27 Jul 2016 10:32:30 +0200 Subject: Handle write config command Signed-off-by: Szczepan Zalega --- include/NitrokeyManager.h | 3 +++ include/stick10_commands.h | 44 ++++++++++++++++++++++++++++++++++++-------- 2 files changed, 39 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h index 47aca83..0f24b1f 100644 --- a/include/NitrokeyManager.h +++ b/include/NitrokeyManager.h @@ -67,6 +67,9 @@ namespace nitrokey { void unlock_user_password(const char *admin_password); + void write_config(bool numlock, bool capslock, bool scrolllock, bool enable_user_password, + bool delete_user_password, const char *admin_temporary_password); + private: NitrokeyManager(); ~NitrokeyManager(); diff --git a/include/stick10_commands.h b/include/stick10_commands.h index 8dc1b22..7a7e2f2 100644 --- a/include/stick10_commands.h +++ b/include/stick10_commands.h @@ -280,9 +280,16 @@ class GetStatus : Command { struct ResponsePayload { uint16_t firmware_version; uint8_t card_serial[4]; - uint8_t general_config[3]; - uint8_t otp_password_config[2]; - + union { + uint8_t general_config[5]; + struct{ + uint8_t numlock; + uint8_t capslock; + uint8_t scrolllock; + uint8_t enable_user_password; + uint8_t delete_user_password; + }; + }; bool isValid() const { return true; } std::string dissect() const { @@ -294,10 +301,13 @@ class GetStatus : Command { ss << "general_config:\t" << ::nitrokey::misc::hexdump((const char *)(general_config), sizeof general_config); - ss << "otp_password_config:\t" - << ::nitrokey::misc::hexdump((const char *)(otp_password_config), - sizeof otp_password_config); - return ss.str(); + ss << "numlock:\t" << (bool)numlock << std::endl; + ss << "capslock:\t" << (bool)capslock << std::endl; + ss << "scrolllock:\t" << (bool)scrolllock << std::endl; + ss << "enable_user_password:\t" << (bool) enable_user_password << std::endl; + ss << "delete_user_password:\t" << (bool) delete_user_password << std::endl; + + return ss.str(); } } __packed; @@ -553,7 +563,25 @@ class PasswordSafeSendSlotViaHID : Command { class WriteGeneralConfig : Command { public: struct CommandPayload { - uint8_t config[5]; + union{ + uint8_t config[5]; + struct{ + uint8_t numlock; + uint8_t capslock; + uint8_t scrolllock; + uint8_t enable_user_password; + uint8_t delete_user_password; + }; + }; + std::string dissect() const { + std::stringstream ss; + ss << "numlock:\t" << (bool)numlock << std::endl; + ss << "capslock:\t" << (bool)capslock << std::endl; + ss << "scrolllock:\t" << (bool)scrolllock << std::endl; + ss << "enable_user_password:\t" << (bool) enable_user_password << std::endl; + ss << "delete_user_password:\t" << (bool) delete_user_password << std::endl; + return ss.str(); + } } __packed; typedef Transaction -- cgit v1.2.3