diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2018-04-10 07:51:15 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2018-04-10 07:51:15 +0200 |
commit | 090af48ee1c49c8655610c7b529b2ca256d9e8ae (patch) | |
tree | 91df1b425d0f3ba39e1c63ec78c7ad376f0427d0 /libnitrokey/stick10_commands.h | |
parent | 0474b8b06d2be6616d4c909e59466af5151e960b (diff) | |
download | libnitrokey-090af48ee1c49c8655610c7b529b2ca256d9e8ae.tar.gz libnitrokey-090af48ee1c49c8655610c7b529b2ca256d9e8ae.tar.bz2 |
Correct validation functions for GetStatus and WriteGeneralConfig structs
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'libnitrokey/stick10_commands.h')
-rw-r--r-- | libnitrokey/stick10_commands.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libnitrokey/stick10_commands.h b/libnitrokey/stick10_commands.h index 893b98f..755b651 100644 --- a/libnitrokey/stick10_commands.h +++ b/libnitrokey/stick10_commands.h @@ -385,10 +385,11 @@ class GetStatus : Command<CommandID::GET_STATUS> { uint8_t capslock; /** same as numlock */ uint8_t scrolllock; /** same as numlock */ uint8_t enable_user_password; - uint8_t delete_user_password; + uint8_t delete_user_password; /* unused */ } __packed; } __packed; - bool isValid() const { return enable_user_password!=delete_user_password; } + + bool isValid() const { return numlock < 2 && capslock < 2 && scrolllock < 2 && enable_user_password < 2; } std::string get_card_serial_hex() const { return nitrokey::misc::toHex(card_serial_u32); @@ -684,7 +685,9 @@ class WriteGeneralConfig : Command<CommandID::WRITE_CONFIG> { uint8_t delete_user_password; }; }; - std::string dissect() const { + bool isValid() const { return numlock < 2 && capslock < 2 && scrolllock < 2 && enable_user_password < 2; } + + std::string dissect() const { std::stringstream ss; ss << "numlock:\t" << (int)numlock << std::endl; ss << "capslock:\t" << (int)capslock << std::endl; |