From 882bdd78f217b994066b78e21f9c64fd396206cc Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Tue, 28 Jul 2020 13:21:33 +0200 Subject: Move missing auth function to OTP unit --- NitrokeyManager.cc | 14 +------------- NitrokeyManagerOTP.cc | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc index fa12a5e..0d566d2 100644 --- a/NitrokeyManager.cc +++ b/NitrokeyManager.cc @@ -20,6 +20,7 @@ */ #include "libnitrokey/NitrokeyManager.h" +#include "NitrokeyManager.h" #include "NitrokeyManagerOTP.h" #include "NitrokeyManagerPWS.h" #include "libnitrokey/LibraryException.h" @@ -41,19 +42,6 @@ namespace nitrokey{ using nitrokey::misc::strcpyT; - - // package type to auth, auth type [Authorize,UserAuthorize] - template - void NitrokeyManager::authorize_packet(T &package, const char *admin_temporary_password, shared_ptr device){ - if (!is_authorization_command_supported()){ - LOG("Authorization command not supported, skipping", Loglevel::WARNING); - } - auto auth = get_payload(); - strcpyT(auth.temporary_password, admin_temporary_password); - auth.crc_to_authorize = S::CommandTransaction::getCRC(package); - A::CommandTransaction::run(device, auth); - } - shared_ptr NitrokeyManager::_instance = nullptr; NitrokeyManager::NitrokeyManager() : device(nullptr) diff --git a/NitrokeyManagerOTP.cc b/NitrokeyManagerOTP.cc index 93f2188..42eb3a9 100644 --- a/NitrokeyManagerOTP.cc +++ b/NitrokeyManagerOTP.cc @@ -324,4 +324,17 @@ nitrokey::NitrokeyManager::get_OTP_slot_data(const uint8_t slot_number) { } nitrokey::proto::stick10::ReadSlot::ResponsePayload nitrokey::NitrokeyManager::get_HOTP_slot_data(const uint8_t slot_number) { return get_OTP_slot_data(get_internal_slot_number_for_hotp(slot_number)); - } \ No newline at end of file + } + namespace nitrokey { // package type to auth, auth type + // [Authorize,UserAuthorize] + template + void NitrokeyManager::authorize_packet(T &package, const char *admin_temporary_password, shared_ptr device){ + if (!is_authorization_command_supported()){ + LOG("Authorization command not supported, skipping", Loglevel::WARNING); + } + auto auth = get_payload(); + strcpyT(auth.temporary_password, admin_temporary_password); + auth.crc_to_authorize = S::CommandTransaction::getCRC(package); + A::CommandTransaction::run(device, auth); + } + } // namespace nitrokey \ No newline at end of file -- cgit v1.2.1