aboutsummaryrefslogtreecommitdiff
path: root/NK_C_API.cc
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2019-06-19 12:06:00 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2019-06-19 14:41:16 +0200
commit2ca5deb106ede1ffd236f153abae8fe6e3b0401c (patch)
tree03ad86918b55e16c3ba00a8f3648cad10a526228 /NK_C_API.cc
parent2c749223714c4d7815ca6b2d1888169a864a0fec (diff)
downloadlibnitrokey-2ca5deb106ede1ffd236f153abae8fe6e3b0401c.tar.gz
libnitrokey-2ca5deb106ede1ffd236f153abae8fe6e3b0401c.tar.bz2
Add function reading HOTP slot details
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'NK_C_API.cc')
-rw-r--r--NK_C_API.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/NK_C_API.cc b/NK_C_API.cc
index ec7bc29..1d3fa3a 100644
--- a/NK_C_API.cc
+++ b/NK_C_API.cc
@@ -881,6 +881,29 @@ NK_C_API char* NK_get_SD_usage_data_as_string() {
}
+ NK_C_API int NK_read_HOTP_slot(const uint8_t slot_num, struct ReadSlot_t* out){
+ if (out == nullptr)
+ return -1;
+ auto m = NitrokeyManager::instance();
+ auto result = get_with_status([&]() {
+ return m->get_HOTP_slot_data(slot_num);
+ }, stick10::ReadSlot::ResponsePayload() );
+ auto error_code = std::get<0>(result);
+ if (error_code != 0) {
+ return error_code;
+ }
+#define a(x) out->x = read_slot.x
+ stick10::ReadSlot::ResponsePayload read_slot = std::get<1>(result);
+ a(_slot_config);
+ a(slot_counter);
+#undef a
+#define m(x) memmove(out->x, read_slot.x, sizeof(read_slot.x))
+ m(slot_name);
+ m(slot_token_id);
+#undef m
+ return 0;
+}
+
#ifdef __cplusplus
}