From 49de98994f234e93cc37e2f01d2927a05880a7e7 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Thu, 8 Sep 2016 16:04:47 +0200 Subject: Allow disabling hexdump header Signed-off-by: Szczepan Zalega --- include/misc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/misc.h b/include/misc.h index a5d9e6d..cccd830 100644 --- a/include/misc.h +++ b/include/misc.h @@ -15,7 +15,7 @@ typename T::CommandPayload get_payload(){ } - std::string hexdump(const char *p, size_t size); + std::string hexdump(const char *p, size_t size, bool print_header=true); uint32_t stm_crc32(const uint8_t *data, size_t size); } } -- cgit v1.2.1 From bcbb54f49fad3f4bb3e8e6aca081d9d300e74d2b Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Thu, 8 Sep 2016 16:05:11 +0200 Subject: Function for getting device's serial number in hex. Fixes #33 Signed-off-by: Szczepan Zalega --- include/NitrokeyManager.h | 1 + include/stick10_commands.h | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h index d2ea991..1e518f4 100644 --- a/include/NitrokeyManager.h +++ b/include/NitrokeyManager.h @@ -40,6 +40,7 @@ namespace nitrokey { bool disconnect(); void set_debug(bool state); string get_status(); + string get_serial_number(); const char * get_totp_slot_name(uint8_t slot_number); const char * get_hotp_slot_name(uint8_t slot_number); diff --git a/include/stick10_commands.h b/include/stick10_commands.h index ef83747..a60be59 100644 --- a/include/stick10_commands.h +++ b/include/stick10_commands.h @@ -324,15 +324,20 @@ class GetStatus : Command { }; bool isValid() const { return enable_user_password!=delete_user_password; } + std::string get_card_serial_hex() const { + return ::nitrokey::misc::hexdump((const char *)(card_serial), + sizeof card_serial, false); + } + std::string dissect() const { std::stringstream ss; ss << "firmware_version:\t" << firmware_version << std::endl; ss << "card_serial:\t" << ::nitrokey::misc::hexdump((const char *)(card_serial), - sizeof card_serial); + sizeof card_serial, false); ss << "general_config:\t" << ::nitrokey::misc::hexdump((const char *)(general_config), - sizeof general_config); + sizeof general_config, false); ss << "numlock:\t" << (int)numlock << std::endl; ss << "capslock:\t" << (int)capslock << std::endl; ss << "scrolllock:\t" << (int)scrolllock << std::endl; -- cgit v1.2.1