From 7d98b54afa3f2276c058dccf38bcfa34a35ed4bb Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Thu, 4 Aug 2016 11:22:47 +0200 Subject: Receive slot config during getting OTP code Signed-off-by: Szczepan Zalega --- include/stick10_commands.h | 58 ++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/include/stick10_commands.h b/include/stick10_commands.h index 342984a..f275993 100644 --- a/include/stick10_commands.h +++ b/include/stick10_commands.h @@ -81,7 +81,6 @@ class SetTime : Command { }; -// TODO duplicate TOTP class WriteToHOTPSlot : Command { public: struct CommandPayload { @@ -160,27 +159,6 @@ class WriteToTOTPSlot : Command { CommandTransaction; }; -class GetCode : Command { - public: - struct CommandPayload { - uint8_t slot_number; - uint64_t challenge; - uint64_t last_totp_time; - uint8_t last_interval; - - bool isValid() const { return !(slot_number & 0xF0); } - } __packed; - - struct ResponsePayload { - uint8_t code[18]; - - bool isValid() const { return true; } - } __packed; - - typedef Transaction CommandTransaction; -}; - class GetTOTP : Command { public: struct CommandPayload { @@ -202,18 +180,28 @@ class GetTOTP : Command { struct ResponsePayload { union { - uint8_t whole_response[18]; //TODO remove if not needed + uint8_t whole_response[18]; //14 bytes reserved for config, but used only 1 struct { uint32_t code; - uint8_t config; - } __packed; - } __packed; + union{ + uint8_t _slot_config; + struct{ + bool use_8_digits : 1; + bool use_enter : 1; + bool use_tokenID : 1; + }; + }; + } __packed ; + } __packed ; bool isValid() const { return true; } std::string dissect() const { std::stringstream ss; ss << "code:\t" << (code) << std::endl; - ss << "config:\t" << "TODO" /*(config) */<< std::endl; //TODO show byte field options + ss << "slot_config:\t" << std::bitset<8>((int)_slot_config) << std::endl; + ss << "\tuse_8_digits(0):\t" << use_8_digits << std::endl; + ss << "\tuse_enter(1):\t" << use_enter << std::endl; + ss << "\tuse_tokenID(2):\t" << use_tokenID << std::endl; return ss.str(); } } __packed; @@ -237,10 +225,17 @@ class GetHOTP : Command { struct ResponsePayload { union { - uint8_t whole_response[18]; //TODO remove if not needed + uint8_t whole_response[18]; //14 bytes reserved for config, but used only 1 struct { uint32_t code; - uint8_t config; + union{ + uint8_t _slot_config; + struct{ + bool use_8_digits : 1; + bool use_enter : 1; + bool use_tokenID : 1; + }; + }; } __packed; } __packed; @@ -248,7 +243,10 @@ class GetHOTP : Command { std::string dissect() const { std::stringstream ss; ss << "code:\t" << (code) << std::endl; - ss << "config:\t" << "TODO" /*(config) */<< std::endl; //TODO show byte field options + ss << "slot_config:\t" << std::bitset<8>((int)_slot_config) << std::endl; + ss << "\tuse_8_digits(0):\t" << use_8_digits << std::endl; + ss << "\tuse_enter(1):\t" << use_enter << std::endl; + ss << "\tuse_tokenID(2):\t" << use_tokenID << std::endl; return ss.str(); } } __packed; -- cgit v1.2.1