aboutsummaryrefslogtreecommitdiff
path: root/include/stick20_commands.h
diff options
context:
space:
mode:
authorszszszsz <szszszsz@users.noreply.github.com>2016-10-19 17:33:30 +0200
committerGitHub <noreply@github.com>2016-10-19 17:33:30 +0200
commit82a0fc21f039971acac18df0ee57e2bb010865e1 (patch)
treef4f487257c99826a6d208fa6ea6f48b4ab7392ed /include/stick20_commands.h
parent10631378c61b7ce54ad6f31dc1d16c3ba4c49d32 (diff)
parente81a132c210e03b6b0a7404a8c96ebda889a5676 (diff)
downloadlibnitrokey-82a0fc21f039971acac18df0ee57e2bb010865e1.tar.gz
libnitrokey-82a0fc21f039971acac18df0ee57e2bb010865e1.tar.bz2
Merge pull request #42 from Nitrokey/13-storage_pro_cmds
Support Pro stick commands on Storage device
Diffstat (limited to 'include/stick20_commands.h')
-rw-r--r--include/stick20_commands.h50
1 files changed, 40 insertions, 10 deletions
diff --git a/include/stick20_commands.h b/include/stick20_commands.h
index c684e95..f4e7500 100644
--- a/include/stick20_commands.h
+++ b/include/stick20_commands.h
@@ -62,6 +62,26 @@ namespace stick20 {
CommandTransaction;
};
+
+ class UnlockUserPassword : Command<CommandID::UNLOCK_USER_PASSWORD> {
+ public:
+ struct CommandPayload {
+ uint8_t kind;
+ uint8_t user_new_password[20];
+ std::string dissect() const {
+ std::stringstream ss;
+ ss << " user_new_password:\t" << user_new_password<< std::endl;
+ return ss.str();
+ }
+ void set_kind(PasswordKind k){
+ kind = (uint8_t)k;
+ }
+ } __packed;
+
+ typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
+ CommandTransaction;
+ };
+
class EnableEncryptedPartition : semantics::non_constructible {
public:
struct CommandPayload {
@@ -126,15 +146,25 @@ class ExportFirmware : semantics::non_constructible {
struct EmptyPayload> CommandTransaction;
};
-class CreateNewKeys : semantics::non_constructible {
- public:
- struct CommandPayload {
- uint8_t password[30];
- };
+ class CreateNewKeys : Command<CommandID::GENERATE_NEW_KEYS> {
+ public:
+ struct CommandPayload {
+ uint8_t kind;
+ uint8_t admin_password[30]; //CS20_MAX_PASSWORD_LEN
+ std::string dissect() const {
+ std::stringstream ss;
+ ss << " admin_password:\t" << admin_password<< std::endl;
+ return ss.str();
+ }
+ void setKindPrefixed(){
+ kind = 'P';
+ }
+ } __packed;
+
+ typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>
+ CommandTransaction;
+ };
- typedef Transaction<CommandID::GENERATE_NEW_KEYS, struct CommandPayload,
- struct EmptyPayload> CommandTransaction;
-};
class FillSDCardWithRandomChars : semantics::non_constructible {
public:
@@ -182,7 +212,7 @@ class SendPasswordMatrixSetup : semantics::non_constructible {
struct EmptyPayload> CommandTransaction;
};
-#define d(x) ss << #x":\t" << x << std::endl;
+#define d(x) ss << " "#x":\t" << (int)x << std::endl;
class GetDeviceStatus : Command<CommandID::GET_DEVICE_STATUS> {
public:
@@ -190,7 +220,7 @@ class SendPasswordMatrixSetup : semantics::non_constructible {
static const int payload_absolute_begin = 8;
static const int padding_size = OUTPUT_CMD_RESULT_STICK20_STATUS_START - payload_absolute_begin;
struct ResponsePayload {
- uint8_t _padding[padding_size];
+ uint8_t _padding[padding_size]; //TODO confirm padding in Storage firmware
//data starts from 21st byte of packet -> 13th byte of payload
uint8_t command_counter;
uint8_t last_command;