diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2016-10-28 11:31:16 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2016-11-26 18:56:25 +0100 |
commit | 9772055e79da77c6ec9ea6992cc77891efc1265a (patch) | |
tree | 8349fee3e4a8fc2cf07825a6c9fd3ec7a1979605 /unittest/test2.cc | |
parent | d58f3fd3bb6df5d3f46e3c4c3b719174e31b7201 (diff) | |
download | libnitrokey-9772055e79da77c6ec9ea6992cc77891efc1265a.tar.gz libnitrokey-9772055e79da77c6ec9ea6992cc77891efc1265a.tar.bz2 |
Test multiple hidden volumes with different passwords and locations
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'unittest/test2.cc')
-rw-r--r-- | unittest/test2.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/unittest/test2.cc b/unittest/test2.cc index d79042a..21122ef 100644 --- a/unittest/test2.cc +++ b/unittest/test2.cc @@ -146,6 +146,38 @@ TEST_CASE("setup hidden volume test", "[hidden]") { execute_password_command<EnableHiddenEncryptedPartition>(stick, hidden_volume_password); } +TEST_CASE("setup multiple hidden volumes", "[hidden2]") { + Stick20 stick; + bool connected = stick.connect(); + REQUIRE(connected == true); + Log::instance().set_loglevel(Loglevel::DEBUG_L2); + + auto user_pin = "123456"; + stick10::LockDevice::CommandTransaction::run(stick); + this_thread::sleep_for(2000ms); + execute_password_command<EnableEncryptedPartition>(stick, user_pin); + + constexpr int volume_count = 4; + for (int i = 0; i < volume_count; ++i) { + auto p = get_payload<stick20::SetupHiddenVolume>(); + p.SlotNr_u8 = i; + p.StartBlockPercent_u8 = 20 + 10*i; + p.EndBlockPercent_u8 = p.StartBlockPercent_u8+i+1; + auto hidden_volume_password = std::string("123123123")+std::to_string(i); + strcpyT(p.HiddenVolumePassword_au8, hidden_volume_password.c_str()); + stick20::SetupHiddenVolume::CommandTransaction::run(stick, p); + this_thread::sleep_for(2000ms); + } + + + for (int i = 0; i < volume_count; ++i) { + execute_password_command<EnableEncryptedPartition>(stick, user_pin); + auto hidden_volume_password = std::string("123123123")+std::to_string(i); + execute_password_command<EnableHiddenEncryptedPartition>(stick, hidden_volume_password.c_str()); + this_thread::sleep_for(2000ms); + } +} + TEST_CASE("general test", "[test]") { Stick20 stick; bool connected = stick.connect(); |