From 448697c66dc7c41d8d948839645a7057bae3dd62 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Thu, 13 Oct 2016 16:58:03 +0200 Subject: NK Storage: cmd output status constants Signed-off-by: Szczepan Zalega --- include/command_id.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/command_id.h') diff --git a/include/command_id.h b/include/command_id.h index 87d270e..45285aa 100644 --- a/include/command_id.h +++ b/include/command_id.h @@ -5,6 +5,16 @@ namespace nitrokey { namespace proto { +#define OUTPUT_CMD_STICK20_STATUS_IDLE 0 +#define OUTPUT_CMD_STICK20_STATUS_OK 1 +#define OUTPUT_CMD_STICK20_STATUS_BUSY 2 +#define OUTPUT_CMD_STICK20_STATUS_WRONG_PASSWORD 3 +#define OUTPUT_CMD_STICK20_STATUS_BUSY_PROGRESSBAR 4 +#define OUTPUT_CMD_STICK20_STATUS_PASSWORD_MATRIX_READY 5 +#define OUTPUT_CMD_STICK20_STATUS_NO_USER_PASSWORD_UNLOCK 6 +#define OUTPUT_CMD_STICK20_STATUS_SMARTCARD_ERROR 7 +#define OUTPUT_CMD_STICK20_STATUS_SECURITY_BIT_ACTIVE 8 + #define STICK20_CMD_START_VALUE 0x20 -- cgit v1.2.1 From 98a9730783268b01d8f55b8b323bb70fdd964a11 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Tue, 18 Oct 2016 15:16:39 +0200 Subject: Code refactoring: replacing magic numbers Signed-off-by: Szczepan Zalega --- include/command_id.h | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'include/command_id.h') diff --git a/include/command_id.h b/include/command_id.h index 45285aa..093de1f 100644 --- a/include/command_id.h +++ b/include/command_id.h @@ -4,18 +4,31 @@ namespace nitrokey { namespace proto { - -#define OUTPUT_CMD_STICK20_STATUS_IDLE 0 -#define OUTPUT_CMD_STICK20_STATUS_OK 1 -#define OUTPUT_CMD_STICK20_STATUS_BUSY 2 -#define OUTPUT_CMD_STICK20_STATUS_WRONG_PASSWORD 3 -#define OUTPUT_CMD_STICK20_STATUS_BUSY_PROGRESSBAR 4 -#define OUTPUT_CMD_STICK20_STATUS_PASSWORD_MATRIX_READY 5 -#define OUTPUT_CMD_STICK20_STATUS_NO_USER_PASSWORD_UNLOCK 6 -#define OUTPUT_CMD_STICK20_STATUS_SMARTCARD_ERROR 7 -#define OUTPUT_CMD_STICK20_STATUS_SECURITY_BIT_ACTIVE 8 - -#define STICK20_CMD_START_VALUE 0x20 + namespace stick20 { + enum class device_status : uint8_t { + idle = 0, + ok, + busy, + wrong_password, + busy_progressbar, + password_matrix_ready, + no_user_password_unlock, + smartcard_error, + security_bit_active + }; + const int CMD_START_VALUE = 0x20; + const int CMD_END_VALUE = 0x60; + } + namespace stick10 { + enum class command_status : uint8_t { + ok = 0, + }; + enum class device_status : uint8_t { + ok = 0, + busy = 1, + wrong_password = 4, + }; + } enum class CommandID : uint8_t { @@ -42,8 +55,8 @@ enum class CommandID : uint8_t { CHANGE_USER_PIN = 0x14, CHANGE_ADMIN_PIN = 0x15, - STICK20_CMD_SEND_PASSWORD = STICK20_CMD_START_VALUE + 18, - STICK20_CMD_SEND_NEW_PASSWORD = STICK20_CMD_START_VALUE + 19, + STICK20_CMD_SEND_PASSWORD = stick20::CMD_START_VALUE + 18, + STICK20_CMD_SEND_NEW_PASSWORD = stick20::CMD_START_VALUE + 19, ENABLE_CRYPTED_PARI = 0x20, DISABLE_CRYPTED_PARI, -- cgit v1.2.1 From 7d579ca0ca59095596275f7b891dacce54398f1f Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Wed, 19 Oct 2016 09:05:25 +0200 Subject: Add all devices' and commands' statuses Signed-off-by: Szczepan Zalega --- include/command_id.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'include/command_id.h') diff --git a/include/command_id.h b/include/command_id.h index 093de1f..8148cc1 100644 --- a/include/command_id.h +++ b/include/command_id.h @@ -22,11 +22,22 @@ namespace proto { namespace stick10 { enum class command_status : uint8_t { ok = 0, + wrong_CRC, + wrong_slot, + slot_not_programmed, + wrong_password = 4, + not_authorized, + timestamp_warning, + no_name_error, + not_supported, + unknown_command, + AES_dec_failed }; enum class device_status : uint8_t { ok = 0, busy = 1, - wrong_password = 4, + error, + received_report, }; } -- cgit v1.2.1