From 2faa8f6782a2e6294ed8849048a281d12d60da1c Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Mon, 4 Dec 2017 16:29:56 +0100 Subject: Initial support for multiple devices with C++ and test Signed-off-by: Szczepan Zalega --- include/NitrokeyManager.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include/NitrokeyManager.h') diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h index 0db0856..2a79922 100644 --- a/include/NitrokeyManager.h +++ b/include/NitrokeyManager.h @@ -30,6 +30,7 @@ #include "stick20_commands.h" #include #include +#include namespace nitrokey { using namespace nitrokey::device; @@ -67,6 +68,8 @@ char * strndup(const char* str, size_t maxlen); bool get_time(uint64_t time = 0); bool erase_totp_slot(uint8_t slot_number, const char *temporary_password); bool erase_hotp_slot(uint8_t slot_number, const char *temporary_password); + std::vector list_devices(); + bool connect_with_path (std::string path); bool connect(const char *device_model); bool connect(); bool disconnect(); @@ -198,8 +201,10 @@ char * strndup(const char* str, size_t maxlen); static shared_ptr _instance; std::shared_ptr device; + std::unordered_map > connected_devices; - stick10::ReadSlot::ResponsePayload get_OTP_slot_data(const uint8_t slot_number); + + stick10::ReadSlot::ResponsePayload get_OTP_slot_data(const uint8_t slot_number); bool is_valid_hotp_slot_number(uint8_t slot_number) const; bool is_valid_totp_slot_number(uint8_t slot_number) const; bool is_valid_password_safe_slot_number(uint8_t slot_number) const; -- cgit v1.2.1 From 388cf5fcb33f24bc04f79cd1fbea980214518d54 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Mon, 4 Dec 2017 19:21:09 +0100 Subject: List devices by unique SC:SD id Add C API and tests Add mutexes Signed-off-by: Szczepan Zalega --- include/NitrokeyManager.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/NitrokeyManager.h') diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h index 2a79922..7ce432f 100644 --- a/include/NitrokeyManager.h +++ b/include/NitrokeyManager.h @@ -69,6 +69,8 @@ char * strndup(const char* str, size_t maxlen); bool erase_totp_slot(uint8_t slot_number, const char *temporary_password); bool erase_hotp_slot(uint8_t slot_number, const char *temporary_password); std::vector list_devices(); + std::vector list_devices_by_cpuID(); + bool connect_with_ID(const std::string id); bool connect_with_path (std::string path); bool connect(const char *device_model); bool connect(); @@ -202,6 +204,7 @@ char * strndup(const char* str, size_t maxlen); static shared_ptr _instance; std::shared_ptr device; std::unordered_map > connected_devices; + std::unordered_map > connected_devices_byID; stick10::ReadSlot::ResponsePayload get_OTP_slot_data(const uint8_t slot_number); -- cgit v1.2.1 From 38c3b4c58e6c6b86d6241183be1814bac2e037d2 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Fri, 16 Feb 2018 15:17:47 +0100 Subject: Log current device ID Allow logger to set global prefix Used to indicate current device Store USB path when used to connection as well Signed-off-by: Szczepan Zalega --- include/NitrokeyManager.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/NitrokeyManager.h') diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h index 7ce432f..5a76616 100644 --- a/include/NitrokeyManager.h +++ b/include/NitrokeyManager.h @@ -203,6 +203,11 @@ char * strndup(const char* str, size_t maxlen); static shared_ptr _instance; std::shared_ptr device; + std::string current_device_id; + public: + const string get_current_device_id() const; + + private: std::unordered_map > connected_devices; std::unordered_map > connected_devices_byID; -- cgit v1.2.1 From f5da7b4cbd508faef38fcdfff659fab5c4649838 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Thu, 1 Mar 2018 11:29:57 +0100 Subject: Minor cleanup Signed-off-by: Szczepan Zalega --- include/NitrokeyManager.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/NitrokeyManager.h') diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h index 5a76616..ca58d24 100644 --- a/include/NitrokeyManager.h +++ b/include/NitrokeyManager.h @@ -70,6 +70,13 @@ char * strndup(const char* str, size_t maxlen); bool erase_hotp_slot(uint8_t slot_number, const char *temporary_password); std::vector list_devices(); std::vector list_devices_by_cpuID(); + + /** + * Connect to the device using unique smartcard:datacard id. + * Needs list_device_by_cpuID() run first + * @param id Current ID of the target device + * @return true on success, false on failure + */ bool connect_with_ID(const std::string id); bool connect_with_path (std::string path); bool connect(const char *device_model); -- cgit v1.2.1