aboutsummaryrefslogtreecommitdiff
path: root/include/NitrokeyManager.h
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-07-18 18:04:34 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-01 13:54:45 +0200
commita5d11eab6003a6ed0f7c78ecb7136b28ee938a23 (patch)
treefa1c5a1a476f51161b822188508704c5acd52a1d /include/NitrokeyManager.h
parent209672f9bba667ea0fc7bce364ef0ad1c8bc4d2a (diff)
downloadlibnitrokey-a5d11eab6003a6ed0f7c78ecb7136b28ee938a23.tar.gz
libnitrokey-a5d11eab6003a6ed0f7c78ecb7136b28ee938a23.tar.bz2
Initial version of C/Python bindings
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'include/NitrokeyManager.h')
-rw-r--r--include/NitrokeyManager.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h
new file mode 100644
index 0000000..37b628d
--- /dev/null
+++ b/include/NitrokeyManager.h
@@ -0,0 +1,56 @@
+#ifndef LIBNITROKEY_NITROKEYMANAGER_H
+#define LIBNITROKEY_NITROKEYMANAGER_H
+
+#include "device.h"
+#include "log.h"
+#include "device_proto.h"
+#include "stick10_commands.h"
+
+namespace nitrokey {
+ using namespace nitrokey::device;
+ using namespace std;
+ using namespace nitrokey::proto::stick10;
+ using namespace nitrokey::proto;
+ using namespace nitrokey::log;
+
+ class NitrokeyManager {
+ public:
+ static NitrokeyManager *instance();
+
+ bool authorize(const char *pin, const char *temporary_password);
+ bool write_HOTP_slot(uint8_t slot_number, const char *slot_name, const char *secret, uint64_t hotp_counter,
+ const char *temporary_password);
+ bool write_TOTP_slot(uint8_t slot_number, const char *secret, uint16_t time_window);
+ uint32_t get_HOTP_code(uint8_t slot_number);
+ uint32_t get_TOTP_code(uint8_t slot_number, uint64_t challenge, uint64_t last_totp_time,
+ uint8_t last_interval);
+ bool erase_totp_slot(uint8_t slot_number);
+ bool erase_hotp_slot(uint8_t slot_number);
+ bool connect();
+ bool disconnect();
+ void set_debug(bool state);
+ string get_status();
+
+ const char * get_totp_slot_name(uint8_t slot_number);
+ const char * get_hotp_slot_name(uint8_t slot_number);
+
+ private:
+ NitrokeyManager();
+ ~NitrokeyManager();
+
+ static NitrokeyManager *_instance;
+ bool connected;
+ Device *device;
+
+ bool is_valid_hotp_slot_number(uint8_t slot_number) const;
+ bool is_valid_totp_slot_number(uint8_t slot_number) const;
+ uint8_t get_internal_slot_number_for_hotp(uint8_t slot_number) const;
+ uint8_t get_internal_slot_number_for_totp(uint8_t slot_number) const;
+ bool erase_slot(uint8_t slot_number);
+ uint8_t *get_slot_name(uint8_t slot_number) const;
+ };
+}
+
+
+
+#endif //LIBNITROKEY_NITROKEYMANAGER_H