diff options
| author | Szczepan Zalega <szczepan@nitrokey.com> | 2016-10-27 21:14:17 +0200 | 
|---|---|---|
| committer | Szczepan Zalega <szczepan@nitrokey.com> | 2016-11-26 18:56:25 +0100 | 
| commit | d58f3fd3bb6df5d3f46e3c4c3b719174e31b7201 (patch) | |
| tree | 75be5acab3f53520832cb36495418d99b231a6c0 | |
| parent | d7ee36dfdfc5a896f5ef7d04b7f1f70f05256ebc (diff) | |
| download | libnitrokey-d58f3fd3bb6df5d3f46e3c4c3b719174e31b7201.tar.gz libnitrokey-d58f3fd3bb6df5d3f46e3c4c3b719174e31b7201.tar.bz2  | |
Support for setting hidden volume and test for it
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
| -rw-r--r-- | include/stick20_commands.h | 19 | ||||
| -rw-r--r-- | unittest/test2.cc | 20 | 
2 files changed, 37 insertions, 2 deletions
diff --git a/include/stick20_commands.h b/include/stick20_commands.h index 4bbb8c0..a1e65c2 100644 --- a/include/stick20_commands.h +++ b/include/stick20_commands.h @@ -282,8 +282,23 @@ namespace nitrokey {                      uint8_t SlotNr_u8;                      uint8_t StartBlockPercent_u8;                      uint8_t EndBlockPercent_u8; -                    uint8_t HiddenVolumePassword_au8[MAX_HIDDEN_VOLUME_PASSOWORD_SIZE + 1]; -                }__packed; +                    uint8_t HiddenVolumePassword_au8[MAX_HIDDEN_VOLUME_PASSOWORD_SIZE + 1]; //last char is a null terminator TODO check if it's needed +                    std::string dissect() const { +                      std::stringstream ss; +                      print_to_ss((int) SlotNr_u8); +                      print_to_ss((int) StartBlockPercent_u8); +                      print_to_ss((int) EndBlockPercent_u8); +                      ss << " HiddenVolumePassword_au8:\t" +                         << HiddenVolumePassword_au8 << std::endl; +                      return ss.str(); +                    } + +                    void set_defaults(){ +                      SlotNr_u8 = 0; +                      StartBlockPercent_u8 = 70; +                      EndBlockPercent_u8 = 90; +                    } +                } __packed;                  typedef Transaction<command_id(), struct CommandPayload, struct EmptyPayload>                      CommandTransaction; diff --git a/unittest/test2.cc b/unittest/test2.cc index 8e3dacc..d79042a 100644 --- a/unittest/test2.cc +++ b/unittest/test2.cc @@ -126,6 +126,26 @@ TEST_CASE("test device internal status with various commands", "[fast]") {    REQUIRE(production_status.data().SD_CardID_u32 != 0);  } +TEST_CASE("setup hidden volume test", "[hidden]") { +  Stick20 stick; +  bool connected = stick.connect(); +  REQUIRE(connected == true); +  Log::instance().set_loglevel(Loglevel::DEBUG_L2); +  stick10::LockDevice::CommandTransaction::run(stick); +  this_thread::sleep_for(2000ms); + +  execute_password_command<EnableEncryptedPartition>(stick, "123456"); + +  auto p = get_payload<stick20::SetupHiddenVolume>(); +  p.set_defaults(); +  auto hidden_volume_password = "123123123"; +  strcpyT(p.HiddenVolumePassword_au8, hidden_volume_password); +  stick20::SetupHiddenVolume::CommandTransaction::run(stick, p); +  this_thread::sleep_for(2000ms); + +  execute_password_command<EnableHiddenEncryptedPartition>(stick, hidden_volume_password); +} +  TEST_CASE("general test", "[test]") {    Stick20 stick;    bool connected = stick.connect();  | 
