aboutsummaryrefslogtreecommitdiff
path: root/include/stick10_commands.h
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-07-27 10:32:30 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-01 13:54:57 +0200
commit8c5b24092faf90672523e60e6eee12a83539ce11 (patch)
tree804244fd1cacc670b8fc5e58264a24d27e269084 /include/stick10_commands.h
parentae8f2596895ba27539409b2399d985b2c613e2d7 (diff)
downloadlibnitrokey-8c5b24092faf90672523e60e6eee12a83539ce11.tar.gz
libnitrokey-8c5b24092faf90672523e60e6eee12a83539ce11.tar.bz2
Handle write config command
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'include/stick10_commands.h')
-rw-r--r--include/stick10_commands.h44
1 files changed, 36 insertions, 8 deletions
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>