From 59ae52487d142fb2b13407419351255c667faa14 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Sat, 13 May 2017 01:15:26 +0200 Subject: Do not log volatile data Signed-off-by: Szczepan Zalega --- include/stick10_commands_0.8.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/stick10_commands_0.8.h') diff --git a/include/stick10_commands_0.8.h b/include/stick10_commands_0.8.h index 4337bb7..3aa60e3 100644 --- a/include/stick10_commands_0.8.h +++ b/include/stick10_commands_0.8.h @@ -90,8 +90,12 @@ namespace nitrokey { ss << "temporary_admin_password:\t" << temporary_admin_password << std::endl; ss << "type:\t" << type << std::endl; ss << "id:\t" << (int)id << std::endl; +#ifdef LOG_VOLATILE_DATA ss << "data:" << std::endl << ::nitrokey::misc::hexdump((const char *) (&data), sizeof data); +#else + ss << " Volatile data not logged" << std::endl; +#endif return ss.str(); } } __packed; @@ -105,8 +109,12 @@ namespace nitrokey { bool isValid() const { return true; } std::string dissect() const { std::stringstream ss; +#ifdef LOG_VOLATILE_DATA ss << "data:" << std::endl << ::nitrokey::misc::hexdump((const char *) (&data), sizeof data); +#else + ss << " Volatile data not logged" << std::endl; +#endif return ss.str(); } } __packed; -- cgit v1.2.1 From 1634bddb91323753546e6fe475d70d41dd79faee Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Sat, 13 May 2017 14:20:40 +0200 Subject: Log temporary password as hexdump instead of string representation Signed-off-by: Szczepan Zalega --- include/stick10_commands_0.8.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'include/stick10_commands_0.8.h') diff --git a/include/stick10_commands_0.8.h b/include/stick10_commands_0.8.h index 3aa60e3..4209380 100644 --- a/include/stick10_commands_0.8.h +++ b/include/stick10_commands_0.8.h @@ -9,13 +9,14 @@ #include #include #include -#include +#include #include "command.h" #include "device_proto.h" #include "stick10_commands.h" #pragma pack (push,1) + namespace nitrokey { namespace proto { @@ -59,6 +60,7 @@ namespace nitrokey { std::string dissect() const { std::stringstream ss; ss << "slot_number:\t" << (int)(slot_number) << std::endl; + hexdump_to_ss(temporary_admin_password); return ss.str(); } } __packed; @@ -87,7 +89,7 @@ namespace nitrokey { std::string dissect() const { std::stringstream ss; - ss << "temporary_admin_password:\t" << temporary_admin_password << std::endl; + hexdump_to_ss(temporary_admin_password); ss << "type:\t" << type << std::endl; ss << "id:\t" << (int)id << std::endl; #ifdef LOG_VOLATILE_DATA @@ -156,7 +158,7 @@ namespace nitrokey { std::string dissect() const { std::stringstream ss; - ss << "temporary_admin_password:\t" << temporary_admin_password << std::endl; + hexdump_to_ss(temporary_admin_password); 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; @@ -192,7 +194,7 @@ namespace nitrokey { bool isValid() const { return (slot_number & 0xF0); } std::string dissect() const { std::stringstream ss; - ss << "temporary_user_password:\t" << temporary_user_password << std::endl; + hexdump_to_ss(temporary_user_password); ss << "slot_number:\t" << (int)(slot_number) << std::endl; return ss.str(); } @@ -244,7 +246,7 @@ namespace nitrokey { bool isValid() const { return !(slot_number & 0xF0); } std::string dissect() const { std::stringstream ss; - ss << "temporary_user_password:\t" << temporary_user_password << std::endl; + hexdump_to_ss(temporary_user_password); ss << "slot_number:\t" << (int)(slot_number) << std::endl; ss << "challenge:\t" << (challenge) << std::endl; ss << "last_totp_time:\t" << (last_totp_time) << std::endl; -- cgit v1.2.1