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/command.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'include/command.h') diff --git a/include/command.h b/include/command.h index fc374f7..bf3cb4e 100644 --- a/include/command.h +++ b/include/command.h @@ -4,6 +4,13 @@ #include "command_id.h" #include "cxx_semantics.h" +#define print_to_ss(x) ( ss << " " << (#x) <<":\t" << (x) << std::endl ); +#ifdef LOG_VOLATILE_DATA +#define print_to_ss_volatile(x) ( ss << " " << (#x) <<":\t" << (x) << std::endl ); +#else +#define print_to_ss_volatile(x) ( ss << " " << (#x) <<":\t" << "***********" << std::endl ); +#endif + namespace nitrokey { namespace proto { @@ -18,7 +25,6 @@ namespace nitrokey { } }; -#define print_to_ss(x) ( ss << " " << (#x) <<":\t" << (x) << std::endl ); namespace stick20{ enum class PasswordKind : uint8_t { User = 'P', @@ -37,7 +43,7 @@ namespace stick20{ std::string dissect() const { std::stringstream ss; print_to_ss( kind ); - print_to_ss(password); + print_to_ss_volatile(password); return ss.str(); } void set_kind_admin() { @@ -79,6 +85,5 @@ namespace stick20{ } } } -#undef print_to_ss #endif -- 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/command.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include/command.h') diff --git a/include/command.h b/include/command.h index bf3cb4e..3f711c0 100644 --- a/include/command.h +++ b/include/command.h @@ -6,10 +6,12 @@ #define print_to_ss(x) ( ss << " " << (#x) <<":\t" << (x) << std::endl ); #ifdef LOG_VOLATILE_DATA -#define print_to_ss_volatile(x) ( ss << " " << (#x) <<":\t" << (x) << std::endl ); +#define print_to_ss_volatile(x) print_to_ss(x); #else #define print_to_ss_volatile(x) ( ss << " " << (#x) <<":\t" << "***********" << std::endl ); #endif +#define hexdump_to_ss(x) (ss << #x":\n"\ + << ::nitrokey::misc::hexdump((const char *) (&x), sizeof x, false)); namespace nitrokey { namespace proto { -- cgit v1.2.1