aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/CommandFailedException.h2
-rw-r--r--include/NKPro_commands.h2
-rw-r--r--include/NKPro_commands_0.8.h52
-rw-r--r--include/NKStorage_commands.h3
-rw-r--r--include/NitrokeyManager.h14
-rw-r--r--include/command.h2
-rw-r--r--include/command_id.h4
-rw-r--r--include/device_proto.h50
-rw-r--r--include/dissect.h34
9 files changed, 81 insertions, 82 deletions
diff --git a/include/CommandFailedException.h b/include/CommandFailedException.h
index 417e850..8434301 100644
--- a/include/CommandFailedException.h
+++ b/include/CommandFailedException.h
@@ -10,7 +10,7 @@
#include "log.h"
#include "command_id.h"
-using cs = nitrokey::proto::stick10::command_status;
+using cs = nitrokey::proto::NKPro::command_status;
class CommandFailedException : public std::exception {
public:
diff --git a/include/NKPro_commands.h b/include/NKPro_commands.h
index e863328..1ed3d4f 100644
--- a/include/NKPro_commands.h
+++ b/include/NKPro_commands.h
@@ -19,7 +19,7 @@ namespace proto {
/*
* Stick10 protocol definition
*/
-namespace stick10 {
+namespace NKPro {
class GetSlotName : public Command<CommandID::READ_SLOT_NAME> {
public:
// reachable as a typedef in Transaction
diff --git a/include/NKPro_commands_0.8.h b/include/NKPro_commands_0.8.h
index 76bb030..2482dec 100644
--- a/include/NKPro_commands_0.8.h
+++ b/include/NKPro_commands_0.8.h
@@ -23,32 +23,32 @@ namespace nitrokey {
/*
* Stick10 protocol definition
*/
- namespace stick10_08 {
- using stick10::FirstAuthenticate;
- using stick10::UserAuthenticate;
- using stick10::SetTime;
- using stick10::GetStatus;
- using stick10::BuildAESKey;
- using stick10::ChangeAdminPin;
- using stick10::ChangeUserPin;
- using stick10::EnablePasswordSafe;
- using stick10::ErasePasswordSafeSlot;
- using stick10::FactoryReset;
- using stick10::GetPasswordRetryCount;
- using stick10::GetUserPasswordRetryCount;
- using stick10::GetPasswordSafeSlotLogin;
- using stick10::GetPasswordSafeSlotName;
- using stick10::GetPasswordSafeSlotPassword;
- using stick10::GetPasswordSafeSlotStatus;
- using stick10::GetSlotName;
- using stick10::IsAESSupported;
- using stick10::LockDevice;
- using stick10::PasswordSafeInitKey;
- using stick10::PasswordSafeSendSlotViaHID;
- using stick10::SetPasswordSafeSlotData;
- using stick10::SetPasswordSafeSlotData2;
- using stick10::UnlockUserPassword;
- using stick10::ReadSlot;
+ namespace NKPro_08 {
+ using NKPro::FirstAuthenticate;
+ using NKPro::UserAuthenticate;
+ using NKPro::SetTime;
+ using NKPro::GetStatus;
+ using NKPro::BuildAESKey;
+ using NKPro::ChangeAdminPin;
+ using NKPro::ChangeUserPin;
+ using NKPro::EnablePasswordSafe;
+ using NKPro::ErasePasswordSafeSlot;
+ using NKPro::FactoryReset;
+ using NKPro::GetPasswordRetryCount;
+ using NKPro::GetUserPasswordRetryCount;
+ using NKPro::GetPasswordSafeSlotLogin;
+ using NKPro::GetPasswordSafeSlotName;
+ using NKPro::GetPasswordSafeSlotPassword;
+ using NKPro::GetPasswordSafeSlotStatus;
+ using NKPro::GetSlotName;
+ using NKPro::IsAESSupported;
+ using NKPro::LockDevice;
+ using NKPro::PasswordSafeInitKey;
+ using NKPro::PasswordSafeSendSlotViaHID;
+ using NKPro::SetPasswordSafeSlotData;
+ using NKPro::SetPasswordSafeSlotData2;
+ using NKPro::UnlockUserPassword;
+ using NKPro::ReadSlot;
class EraseSlot : Command<CommandID::ERASE_SLOT> {
public:
diff --git a/include/NKStorage_commands.h b/include/NKStorage_commands.h
index 5f99d28..b375617 100644
--- a/include/NKStorage_commands.h
+++ b/include/NKStorage_commands.h
@@ -18,8 +18,7 @@ namespace nitrokey {
* STICK20 protocol command ids
* a superset (almost) of STICK10
*/
-
- namespace stick20 {
+ namespace NKStorage {
class ChangeAdminUserPin20Current :
public PasswordCommand<CommandID::SEND_PASSWORD, PasswordKind::Admin> {};
diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h
index f6977d9..216ff88 100644
--- a/include/NitrokeyManager.h
+++ b/include/NitrokeyManager.h
@@ -13,8 +13,8 @@
namespace nitrokey {
using namespace nitrokey::device;
using namespace std;
- using namespace nitrokey::proto::stick10;
- using namespace nitrokey::proto::stick20;
+ using namespace nitrokey::proto::NKPro;
+ using namespace nitrokey::proto::NKStorage;
using namespace nitrokey::proto;
using namespace nitrokey::log;
@@ -39,8 +39,8 @@ char * strndup(const char* str, size_t maxlen);
uint8_t last_interval,
const char *user_temporary_password);
string get_TOTP_code(uint8_t slot_number, const char *user_temporary_password);
- stick10::ReadSlot::ResponsePayload get_TOTP_slot_data(const uint8_t slot_number);
- stick10::ReadSlot::ResponsePayload get_HOTP_slot_data(const uint8_t slot_number);
+ NKPro::ReadSlot::ResponsePayload get_TOTP_slot_data(const uint8_t slot_number);
+ NKPro::ReadSlot::ResponsePayload get_HOTP_slot_data(const uint8_t slot_number);
bool set_time(uint64_t time);
bool get_time(uint64_t time = 0);
@@ -55,7 +55,7 @@ char * strndup(const char* str, size_t maxlen);
DeviceModel get_connected_device_model() const;
void set_debug(bool state);
- stick10::GetStatus::ResponsePayload get_status();
+ NKPro::GetStatus::ResponsePayload get_status();
string get_status_as_string();
string get_serial_number();
@@ -126,7 +126,7 @@ char * strndup(const char* str, size_t maxlen);
void send_startup(uint64_t seconds_from_epoch);
const char * get_status_storage_as_string();
- stick20::DeviceConfigurationResponsePacket::ResponsePayload get_status_storage();
+ NKStorage::DeviceConfigurationResponsePacket::ResponsePayload get_status_storage();
const char *get_SD_usage_data_as_string();
std::pair<uint8_t,uint8_t> get_SD_usage_data();
@@ -150,7 +150,7 @@ char * strndup(const char* str, size_t maxlen);
static shared_ptr <NitrokeyManager> _instance;
std::shared_ptr<Device> device;
- stick10::ReadSlot::ResponsePayload get_OTP_slot_data(const uint8_t slot_number);
+ NKPro::ReadSlot::ResponsePayload get_OTP_slot_data(const uint8_t slot_number);
bool is_valid_hotp_slot_number(uint8_t slot_number) const;
bool is_valid_totp_slot_number(uint8_t slot_number) const;
bool is_valid_password_safe_slot_number(uint8_t slot_number) const;
diff --git a/include/command.h b/include/command.h
index 3f711c0..4710cbd 100644
--- a/include/command.h
+++ b/include/command.h
@@ -27,7 +27,7 @@ namespace nitrokey {
}
};
-namespace stick20{
+namespace NKStorage{
enum class PasswordKind : uint8_t {
User = 'P',
Admin = 'A',
diff --git a/include/command_id.h b/include/command_id.h
index d1246dd..cde75f1 100644
--- a/include/command_id.h
+++ b/include/command_id.h
@@ -4,7 +4,7 @@
namespace nitrokey {
namespace proto {
- namespace stick20 {
+ namespace NKStorage {
enum class device_status : uint8_t {
idle = 0,
ok,
@@ -19,7 +19,7 @@ namespace proto {
const int CMD_START_VALUE = 0x20;
const int CMD_END_VALUE = 0x60;
}
- namespace stick10 {
+ namespace NKPro {
enum class command_status : uint8_t {
ok = 0,
wrong_CRC,
diff --git a/include/device_proto.h b/include/device_proto.h
index b557384..4abb7b8 100644
--- a/include/device_proto.h
+++ b/include/device_proto.h
@@ -120,7 +120,7 @@ namespace nitrokey {
uint8_t _storage_status_padding[storage_status_padding_size];
uint8_t command_counter;
uint8_t command_id;
- uint8_t device_status; //@see stick20::device_status
+ uint8_t device_status; //@see NKStorage::device_status
uint8_t progress_bar_value;
} __packed storage_status;
} __packed;
@@ -269,24 +269,24 @@ namespace nitrokey {
status = dev->recv(&resp);
if (dev->get_device_model() == DeviceModel::STORAGE &&
- resp.command_id >= stick20::CMD_START_VALUE &&
- resp.command_id < stick20::CMD_END_VALUE ) {
+ resp.command_id >= NKStorage::CMD_START_VALUE &&
+ resp.command_id < NKStorage::CMD_END_VALUE ) {
LOG(std::string("Detected storage device cmd, status: ") +
std::to_string(resp.storage_status.device_status), Loglevel::DEBUG_L2);
- resp.last_command_status = static_cast<uint8_t>(stick10::command_status::ok);
- switch (static_cast<stick20::device_status>(resp.storage_status.device_status)) {
- case stick20::device_status::idle :
- case stick20::device_status::ok:
- resp.device_status = static_cast<uint8_t>(stick10::device_status::ok);
+ resp.last_command_status = static_cast<uint8_t>(NKPro::command_status::ok);
+ switch (static_cast<NKStorage::device_status>(resp.storage_status.device_status)) {
+ case NKStorage::device_status::idle :
+ case NKStorage::device_status::ok:
+ resp.device_status = static_cast<uint8_t>(NKPro::device_status::ok);
break;
- case stick20::device_status::busy:
- case stick20::device_status::busy_progressbar: //TODO this will be modified later for getting progressbar status
- resp.device_status = static_cast<uint8_t>(stick10::device_status::busy);
+ case NKStorage::device_status::busy:
+ case NKStorage::device_status::busy_progressbar: //TODO this will be modified later for getting progressbar status
+ resp.device_status = static_cast<uint8_t>(NKPro::device_status::busy);
break;
- case stick20::device_status::wrong_password:
- resp.last_command_status = static_cast<uint8_t>(stick10::command_status::wrong_password);
- resp.device_status = static_cast<uint8_t>(stick10::device_status::ok);
+ case NKStorage::device_status::wrong_password:
+ resp.last_command_status = static_cast<uint8_t>(NKPro::command_status::wrong_password);
+ resp.device_status = static_cast<uint8_t>(NKPro::device_status::ok);
break;
default:
LOG(std::string("Unknown storage device status, cannot translate: ") +
@@ -299,12 +299,12 @@ namespace nitrokey {
//SENDPASSWORD gives wrong CRC , for now rely on !=0 (TODO report)
// if (resp.device_status == 0 && resp.last_command_crc == outp.crc && resp.isCRCcorrect()) break;
auto CRC_equal_awaited = resp.last_command_crc == outp.crc;
- if (resp.device_status == static_cast<uint8_t>(stick10::device_status::ok) &&
+ if (resp.device_status == static_cast<uint8_t>(NKPro::device_status::ok) &&
CRC_equal_awaited && resp.isValid()){
successful_communication = true;
break;
}
- if (resp.device_status == static_cast<uint8_t>(stick10::device_status::busy)) {
+ if (resp.device_status == static_cast<uint8_t>(NKPro::device_status::busy)) {
dev->m_counters.busy++;
if (busy_counter++<10) {
receiving_retry_counter++;
@@ -318,9 +318,9 @@ namespace nitrokey {
+ std::to_string(retry_timeout.count()), Loglevel::DEBUG);
}
}
- if (resp.device_status == static_cast<uint8_t>(stick10::device_status::busy) &&
- static_cast<stick20::device_status>(resp.storage_status.device_status)
- == stick20::device_status::busy_progressbar){
+ if (resp.device_status == static_cast<uint8_t>(NKPro::device_status::busy) &&
+ static_cast<NKStorage::device_status>(resp.storage_status.device_status)
+ == NKStorage::device_status::busy_progressbar){
successful_communication = true;
break;
}
@@ -371,9 +371,9 @@ namespace nitrokey {
LOG(std::string("receiving_retry_counter count: ") + std::to_string(receiving_retry_counter),
Loglevel::DEBUG_L2);
- if (resp.device_status == static_cast<uint8_t>(stick10::device_status::busy) &&
- static_cast<stick20::device_status>(resp.storage_status.device_status)
- == stick20::device_status::busy_progressbar){
+ if (resp.device_status == static_cast<uint8_t>(NKPro::device_status::busy) &&
+ static_cast<NKStorage::device_status>(resp.storage_status.device_status)
+ == NKStorage::device_status::busy_progressbar){
dev->m_counters.busy_progressbar++;
throw LongOperationInProgressException(
resp.command_id, resp.device_status, resp.storage_status.progress_bar_value);
@@ -385,7 +385,7 @@ namespace nitrokey {
"Maximum receiving_retry_counter count reached for receiving response from the device!");
dev->m_counters.communication_successful++;
- if (resp.last_command_status != static_cast<uint8_t>(stick10::command_status::ok)){
+ if (resp.last_command_status != static_cast<uint8_t>(NKPro::command_status::ok)){
dev->m_counters.command_result_not_equal_0_recv++;
throw CommandFailedException(resp.command_id, resp.last_command_status);
}
@@ -393,8 +393,8 @@ namespace nitrokey {
dev->m_counters.command_successful_recv++;
if (dev->get_device_model() == DeviceModel::STORAGE &&
- resp.command_id >= stick20::CMD_START_VALUE &&
- resp.command_id < stick20::CMD_END_VALUE ) {
+ resp.command_id >= NKStorage::CMD_START_VALUE &&
+ resp.command_id < NKStorage::CMD_END_VALUE ) {
dev->m_counters.successful_storage_commands++;
}
diff --git a/include/dissect.h b/include/dissect.h
index 69a5129..8ff392a 100644
--- a/include/dissect.h
+++ b/include/dissect.h
@@ -45,12 +45,12 @@ template <CommandID id, class HIDPacket>
class ResponseDissector : semantics::non_constructible {
public:
static std::string status_translate_device(int status){
- auto enum_status = static_cast<proto::stick10::device_status>(status);
+ auto enum_status = static_cast<proto::NKPro::device_status>(status);
switch (enum_status){
- case stick10::device_status::ok: return "OK";
- case stick10::device_status::busy: return "BUSY";
- case stick10::device_status::error: return "ERROR";
- case stick10::device_status::received_report: return "RECEIVED_REPORT";
+ case NKPro::device_status::ok: return "OK";
+ case NKPro::device_status::busy: return "BUSY";
+ case NKPro::device_status::error: return "ERROR";
+ case NKPro::device_status::received_report: return "RECEIVED_REPORT";
}
return std::string("UNKNOWN: ") + std::to_string(status);
}
@@ -60,20 +60,20 @@ class ResponseDissector : semantics::non_constructible {
return str;
}
static std::string status_translate_command(int status){
- auto enum_status = static_cast<proto::stick10::command_status >(status);
+ auto enum_status = static_cast<proto::NKPro::command_status >(status);
switch (enum_status) {
#define p(X) case X: return to_upper(std::string(#X));
- p(stick10::command_status::ok)
- p(stick10::command_status::wrong_CRC)
- p(stick10::command_status::wrong_slot)
- p(stick10::command_status::slot_not_programmed)
- p(stick10::command_status::wrong_password)
- p(stick10::command_status::not_authorized)
- p(stick10::command_status::timestamp_warning)
- p(stick10::command_status::no_name_error)
- p(stick10::command_status::not_supported)
- p(stick10::command_status::unknown_command)
- p(stick10::command_status::AES_dec_failed)
+ p(NKPro::command_status::ok)
+ p(NKPro::command_status::wrong_CRC)
+ p(NKPro::command_status::wrong_slot)
+ p(NKPro::command_status::slot_not_programmed)
+ p(NKPro::command_status::wrong_password)
+ p(NKPro::command_status::not_authorized)
+ p(NKPro::command_status::timestamp_warning)
+ p(NKPro::command_status::no_name_error)
+ p(NKPro::command_status::not_supported)
+ p(NKPro::command_status::unknown_command)
+ p(NKPro::command_status::AES_dec_failed)
#undef p
}
return std::string("UNKNOWN: ") + std::to_string(status);