diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2018-03-02 11:41:13 +0100 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2018-03-02 11:41:13 +0100 |
commit | 379daf936caa7fc8d7311a5dda101edb40d35ca5 (patch) | |
tree | 2d186dec6976b12a9f7b37e589c02703275a30ef /include/NitrokeyManager.h | |
parent | d5486ba77235a874245fbee07a75cea89fa59ea2 (diff) | |
parent | c3d615b659b608f3a1d624f6fc78c303efbe1f8e (diff) | |
download | libnitrokey-379daf936caa7fc8d7311a5dda101edb40d35ca5.tar.gz libnitrokey-379daf936caa7fc8d7311a5dda101edb40d35ca5.tar.bz2 |
Merge branch 'wip-multiple_devices'
Allow to use multiple devices, iteratively.
Storage only.
Diffstat (limited to 'include/NitrokeyManager.h')
-rw-r--r-- | include/NitrokeyManager.h | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h index 0db0856..ca58d24 100644 --- a/include/NitrokeyManager.h +++ b/include/NitrokeyManager.h @@ -30,6 +30,7 @@ #include "stick20_commands.h" #include <vector> #include <memory> +#include <unordered_map> namespace nitrokey { using namespace nitrokey::device; @@ -67,6 +68,17 @@ 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<std::string> list_devices(); + std::vector<std::string> 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); bool connect(); bool disconnect(); @@ -198,8 +210,16 @@ char * strndup(const char* str, size_t maxlen); static shared_ptr <NitrokeyManager> _instance; std::shared_ptr<Device> device; + std::string current_device_id; + public: + const string get_current_device_id() const; + + private: + std::unordered_map<std::string, shared_ptr<Device> > connected_devices; + std::unordered_map<std::string, shared_ptr<Device> > connected_devices_byID; + - 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; |