From d26e07e7a4a5066f69364aebf13eda35490bea5c Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Wed, 19 Oct 2016 12:30:34 +0200 Subject: Handle HOTP counters as strings for Storage Signed-off-by: Szczepan Zalega --- NitrokeyManager.cc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc index a01dbec..7f3bfd0 100644 --- a/NitrokeyManager.cc +++ b/NitrokeyManager.cc @@ -13,7 +13,7 @@ namespace nitrokey{ // throw EmptySourceStringException(slot_number); return; const size_t s_dest = sizeof dest; - nitrokey::log::Log::instance()(std::string("strcpyT sizes ") + nitrokey::log::Log::instance()(std::string("strcpyT sizes dest src ") +std::to_string(s_dest)+ " " +std::to_string(strlen(src))+ " " ,nitrokey::log::Loglevel::DEBUG); @@ -191,7 +191,22 @@ namespace nitrokey{ vector_copy(payload.slot_secret, secret_bin); strcpyT(payload.slot_name, slot_name); strcpyT(payload.slot_token_id, token_ID); - payload.slot_counter = hotp_counter; + switch (device->get_device_model() ){ + case DeviceModel::PRO: { + payload.slot_counter = hotp_counter; + break; + } + case DeviceModel::STORAGE: { + std::string counter = std::to_string(hotp_counter); + strcpyT(payload.slot_counter, counter.c_str()); + break; + } + default: + nitrokey::log::Log::instance()( std::string(__FILE__) + std::to_string(__LINE__) + + std::string(__FUNCTION__) + std::string(" Unhandled device model for HOTP") + , nitrokey::log::Loglevel::DEBUG); + break; + } payload.use_8_digits = use_8_digits; payload.use_enter = use_enter; payload.use_tokenID = use_tokenID; -- cgit v1.2.3