aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/CommandFailedException.h5
-rw-r--r--include/NitrokeyManager.h53
-rw-r--r--include/command_id.h7
-rw-r--r--include/device_proto.h10
-rw-r--r--include/stick10_commands.h8
-rw-r--r--include/stick20_commands.h24
6 files changed, 98 insertions, 9 deletions
diff --git a/include/CommandFailedException.h b/include/CommandFailedException.h
index 42fad73..32bd6b7 100644
--- a/include/CommandFailedException.h
+++ b/include/CommandFailedException.h
@@ -28,6 +28,7 @@
#include "command_id.h"
using cs = nitrokey::proto::stick10::command_status;
+using cs2 = nitrokey::proto::stick20::device_status;
class CommandFailedException : public std::exception {
public:
@@ -65,6 +66,10 @@ public:
return last_command_status == static_cast<uint8_t>(cs::wrong_password);
}
+ bool reason_smartcard_busy() const throw(){
+ return last_command_status == static_cast<uint8_t>(cs2::smartcard_error);
+ }
+
};
diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h
index 9a1686c..0db0856 100644
--- a/include/NitrokeyManager.h
+++ b/include/NitrokeyManager.h
@@ -126,10 +126,38 @@ char * strndup(const char* str, size_t maxlen);
void unlock_hidden_volume(const char *hidden_volume_password);
void lock_hidden_volume();
+ /**
+ * Sets unencrypted volume read-only.
+ * Works until v0.48 (incl. v0.50), where User PIN was sufficient
+ * Does nothing otherwise.
+ * @param user_pin User PIN
+ */
void set_unencrypted_read_only(const char *user_pin);
+ /**
+ * Sets unencrypted volume read-only.
+ * Works from v0.49 (except v0.50) accepts Admin PIN
+ * Does nothing otherwise.
+ * @param admin_pin Admin PIN
+ */
+ void set_unencrypted_read_only_admin(const char *admin_pin);
+
+ /**
+ * Sets unencrypted volume read-write.
+ * Works until v0.48 (incl. v0.50), where User PIN was sufficient
+ * Does nothing otherwise.
+ * @param user_pin User PIN
+ */
void set_unencrypted_read_write(const char *user_pin);
+ /**
+ * Sets unencrypted volume read-write.
+ * Works from v0.49 (except v0.50) accepts Admin PIN
+ * Does nothing otherwise.
+ * @param admin_pin Admin PIN
+ */
+ void set_unencrypted_read_write_admin(const char *admin_pin);
+
void export_firmware(const char *admin_pin);
void enable_firmware_update(const char *firmware_pin);
@@ -202,6 +230,31 @@ char * strndup(const char* str, size_t maxlen);
void set_loglevel(Loglevel loglevel);
void set_loglevel(int loglevel);
+
+ /**
+ * Sets encrypted volume read-only.
+ * Supported from future versions of Storage.
+ * @param admin_pin Admin PIN
+ */
+ void set_encrypted_volume_read_only(const char *admin_pin);
+
+ /**
+ * Sets encrypted volume read-write.
+ * Supported from future versions of Storage.
+ * @param admin_pin Admin PIN
+ */
+ void set_encrypted_volume_read_write(const char *admin_pin);
+
+ int get_major_firmware_version();
+
+ bool is_smartcard_in_use();
+
+ /**
+ * Function to determine unencrypted volume PIN type
+ * @param minor_firmware_version
+ * @return Returns true, if set unencrypted volume ro/rw pin type is User, false otherwise.
+ */
+ bool set_unencrypted_volume_rorw_pin_type_user();
};
}
diff --git a/include/command_id.h b/include/command_id.h
index 7608201..1092ea9 100644
--- a/include/command_id.h
+++ b/include/command_id.h
@@ -124,6 +124,13 @@ enum class CommandID : uint8_t {
CHANGE_UPDATE_PIN = 0x20 + 26,
+ //added in v0.48.5
+ ENABLE_ADMIN_READONLY_UNCRYPTED_LUN = 0x20 + 28,
+ ENABLE_ADMIN_READWRITE_UNCRYPTED_LUN = 0x20 + 29,
+ ENABLE_ADMIN_READONLY_ENCRYPTED_LUN = 0x20 + 30,
+ ENABLE_ADMIN_READWRITE_ENCRYPTED_LUN = 0x20 + 31,
+ CHECK_SMARTCARD_USAGE = 0x20 + 32,
+
GET_PW_SAFE_SLOT_STATUS = 0x60,
GET_PW_SAFE_SLOT_NAME = 0x61,
GET_PW_SAFE_SLOT_PASSWORD = 0x62,
diff --git a/include/device_proto.h b/include/device_proto.h
index 7873a0a..ebdcdbd 100644
--- a/include/device_proto.h
+++ b/include/device_proto.h
@@ -351,12 +351,14 @@ namespace nitrokey {
LOG("Status busy, decreasing receiving_retry_counter counter: " +
std::to_string(receiving_retry_counter) + ", current delay:"
+ std::to_string(retry_timeout.count()), Loglevel::DEBUG);
- LOG(std::string("Busy retry ")
+ LOG(std::string("Busy retry: status ")
+ std::to_string(resp.storage_status.device_status)
- + " "
+ + ", "
+ std::to_string(retry_timeout.count())
- + " "
+ + "ms, counter "
+ std::to_string(receiving_retry_counter)
+ + ", progress: "
+ + std::to_string(resp.storage_status.progress_bar_value)
, Loglevel::DEBUG_L1);
}
}
@@ -454,7 +456,7 @@ namespace nitrokey {
if (resp.last_command_status != static_cast<uint8_t>(stick10::command_status::ok)){
dev->m_counters.command_result_not_equal_0_recv++;
- LOG(std::string("Throw: CommandFailedException"), Loglevel::DEBUG_L1);
+ LOG(std::string("Throw: CommandFailedException ") + std::to_string(resp.last_command_status), Loglevel::DEBUG_L1);
throw CommandFailedException(resp.command_id, resp.last_command_status);
}
diff --git a/include/stick10_commands.h b/include/stick10_commands.h
index c9a5e5b..893b98f 100644
--- a/include/stick10_commands.h
+++ b/include/stick10_commands.h
@@ -367,7 +367,13 @@ class ReadSlot : Command<CommandID::READ_SLOT> {
class GetStatus : Command<CommandID::GET_STATUS> {
public:
struct ResponsePayload {
- uint16_t firmware_version;
+ union {
+ uint16_t firmware_version;
+ struct {
+ uint8_t minor;
+ uint8_t major;
+ } firmware_version_st;
+ };
union{
uint8_t card_serial[4];
uint32_t card_serial_u32;
diff --git a/include/stick20_commands.h b/include/stick20_commands.h
index 34bd547..4b75e6a 100644
--- a/include/stick20_commands.h
+++ b/include/stick20_commands.h
@@ -52,6 +52,15 @@ namespace nitrokey {
class EnableEncryptedPartition : public PasswordCommand<CommandID::ENABLE_CRYPTED_PARI> {};
class EnableHiddenEncryptedPartition : public PasswordCommand<CommandID::ENABLE_HIDDEN_CRYPTED_PARI> {};
+ class SetUnencryptedVolumeReadOnlyAdmin :
+ public PasswordCommand<CommandID::ENABLE_ADMIN_READONLY_UNCRYPTED_LUN, PasswordKind::Admin> {};
+ class SetUnencryptedVolumeReadWriteAdmin :
+ public PasswordCommand<CommandID::ENABLE_ADMIN_READWRITE_UNCRYPTED_LUN, PasswordKind::Admin> {};
+ class SetEncryptedVolumeReadOnly :
+ public PasswordCommand<CommandID::ENABLE_ADMIN_READONLY_ENCRYPTED_LUN, PasswordKind::Admin> {};
+ class SetEncryptedVolumeReadWrite :
+ public PasswordCommand<CommandID::ENABLE_ADMIN_READWRITE_ENCRYPTED_LUN, PasswordKind::Admin> {};
+
//FIXME the volume disabling commands do not need password
class DisableEncryptedPartition : public PasswordCommand<CommandID::DISABLE_CRYPTED_PARI> {};
class DisableHiddenEncryptedPartition : public PasswordCommand<CommandID::DISABLE_HIDDEN_CRYPTED_PARI> {};
@@ -159,10 +168,10 @@ namespace nitrokey {
union{
uint8_t VersionInfo_au8[4];
struct {
- uint8_t _reserved;
+ uint8_t major;
uint8_t minor;
uint8_t _reserved2;
- uint8_t major;
+ uint8_t build_iteration;
} __packed versionInfo;
} __packed;
@@ -206,8 +215,9 @@ namespace nitrokey {
print_to_ss((int) ReadWriteFlagUncryptedVolume_u8 );
print_to_ss((int) ReadWriteFlagCryptedVolume_u8 );
print_to_ss((int) ReadWriteFlagHiddenVolume_u8 );
- print_to_ss((int) VersionInfo_au8[1] );
- print_to_ss((int) VersionInfo_au8[3] );
+ print_to_ss((int) versionInfo.major );
+ print_to_ss((int) versionInfo.minor );
+ print_to_ss((int) versionInfo.build_iteration );
print_to_ss((int) FirmwareLocked_u8 );
print_to_ss((int) NewSDCardFound_u8 );
print_to_ss((int) NewSDCardFound_st.NewCard );
@@ -265,6 +275,12 @@ namespace nitrokey {
CommandTransaction;
};
+ class CheckSmartcardUsage : Command<CommandID::CHECK_SMARTCARD_USAGE> {
+ public:
+ typedef Transaction<command_id(), struct EmptyPayload, EmptyPayload>
+ CommandTransaction;
+ };
+
class GetSDCardOccupancy : Command<CommandID::SD_CARD_HIGH_WATERMARK> {
public:
struct ResponsePayload {