aboutsummaryrefslogtreecommitdiff
path: root/NK_C_API.cc
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-07-27 18:29:54 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-01 13:54:57 +0200
commit20f5f690b15d1d245555f8c3aab4a502781cdeb4 (patch)
treeb7082cabd556713b601bbf74823a6288abf3ff43 /NK_C_API.cc
parent5f3e5514f0fad2b59f24b687fc8501a26eaf0ab5 (diff)
downloadlibnitrokey-20f5f690b15d1d245555f8c3aab4a502781cdeb4.tar.gz
libnitrokey-20f5f690b15d1d245555f8c3aab4a502781cdeb4.tar.bz2
Authorizing getting OTP codes - initial version
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'NK_C_API.cc')
-rw-r--r--NK_C_API.cc17
1 files changed, 13 insertions, 4 deletions
diff --git a/NK_C_API.cc b/NK_C_API.cc
index d93fafc..ff7ecae 100644
--- a/NK_C_API.cc
+++ b/NK_C_API.cc
@@ -154,10 +154,15 @@ extern const char * NK_status() {
return "";
}
-extern uint32_t NK_get_hotp_code(uint8_t slot_number){
+
+extern uint32_t NK_get_hotp_code(uint8_t slot_number) {
+ return NK_get_hotp_code_PIN(slot_number, "");
+}
+
+extern uint32_t NK_get_hotp_code_PIN(uint8_t slot_number, const char* user_temporary_password){
auto m = NitrokeyManager::instance();
try {
- return m->get_HOTP_code(slot_number);
+ return m->get_HOTP_code(slot_number, user_temporary_password);
}
catch (CommandFailedException & commandFailedException){
NK_last_command_status = commandFailedException.last_command_status;
@@ -167,9 +172,14 @@ extern uint32_t NK_get_hotp_code(uint8_t slot_number){
extern uint32_t NK_get_totp_code(uint8_t slot_number, uint64_t challenge, uint64_t last_totp_time,
uint8_t last_interval){
+ return NK_get_totp_code_PIN(slot_number, challenge, last_totp_time, last_interval, "");
+}
+
+extern uint32_t NK_get_totp_code_PIN(uint8_t slot_number, uint64_t challenge, uint64_t last_totp_time,
+ uint8_t last_interval, const char* user_temporary_password){
auto m = NitrokeyManager::instance();
try {
- return m->get_TOTP_code(slot_number, challenge, last_totp_time, last_interval);
+ return m->get_TOTP_code(slot_number, challenge, last_totp_time, last_interval, user_temporary_password);
}
catch (CommandFailedException & commandFailedException){
NK_last_command_status = commandFailedException.last_command_status;
@@ -380,6 +390,5 @@ extern int NK_erase_password_safe_slot(uint8_t slot_number) {
});
}
-
}