diff options
| author | Szczepan Zalega <szczepan@nitrokey.com> | 2016-07-27 10:32:30 +0200 | 
|---|---|---|
| committer | Szczepan Zalega <szczepan@nitrokey.com> | 2016-08-01 13:54:57 +0200 | 
| commit | 8c5b24092faf90672523e60e6eee12a83539ce11 (patch) | |
| tree | 804244fd1cacc670b8fc5e58264a24d27e269084 /include | |
| parent | ae8f2596895ba27539409b2399d985b2c613e2d7 (diff) | |
| download | libnitrokey-8c5b24092faf90672523e60e6eee12a83539ce11.tar.gz libnitrokey-8c5b24092faf90672523e60e6eee12a83539ce11.tar.bz2 | |
Handle write config command
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/NitrokeyManager.h | 3 | ||||
| -rw-r--r-- | include/stick10_commands.h | 44 | 
2 files changed, 39 insertions, 8 deletions
| 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<CommandID::GET_STATUS> {    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<CommandID::GET_STATUS> {        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<CommandID::PW_SAFE_SEND_DATA> {  class WriteGeneralConfig : Command<CommandID::WRITE_CONFIG> {   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<command_id(), struct CommandPayload, struct EmptyPayload> | 
