diff options
| -rw-r--r-- | include/stick20_commands.h | 12 | ||||
| -rw-r--r-- | unittest/test2.cc | 25 | 
2 files changed, 31 insertions, 6 deletions
diff --git a/include/stick20_commands.h b/include/stick20_commands.h index a1e65c2..676b3df 100644 --- a/include/stick20_commands.h +++ b/include/stick20_commands.h @@ -99,15 +99,17 @@ namespace nitrokey {              class DisableHiddenEncryptedPartition : public PasswordCommand<CommandID::DISABLE_CRYPTED_PARI> {};              class EnableFirmwareUpdate : public PasswordCommand<CommandID::ENABLE_FIRMWARE_UPDATE> {}; -            class UpdatePassword : Command<CommandID::CHANGE_UPDATE_PIN> { +            class ChangeUpdatePassword : Command<CommandID::CHANGE_UPDATE_PIN> {              public:                  struct CommandPayload { -                    uint8_t old_password[15]; -                    uint8_t new_password[15]; +                    uint8_t __gap; +                    uint8_t current_update_password[20]; +                    uint8_t __gap2; +                    uint8_t new_update_password[20];                      std::string dissect() const {                        std::stringstream ss; -                      print_to_ss( old_password ); -                      print_to_ss( new_password ); +                      print_to_ss( current_update_password ); +                      print_to_ss( new_update_password );                        return ss.str();                      }                  }; diff --git a/unittest/test2.cc b/unittest/test2.cc index 21122ef..8db91b7 100644 --- a/unittest/test2.cc +++ b/unittest/test2.cc @@ -178,7 +178,30 @@ TEST_CASE("setup multiple hidden volumes", "[hidden2]") {    }  } -TEST_CASE("general test", "[test]") { +//in case of a bug this could change update PIN to some unexpected value +// - please save log with packet dump if this test will not pass +TEST_CASE("update password change", "[dangerous]") { +  Stick20 stick; +  bool connected = stick.connect(); +  REQUIRE(connected == true); +  Log::instance().set_loglevel(Loglevel::DEBUG_L2); + +  auto pass1 = "12345678"; +  auto pass2 = "12345678901234567890"; + +  auto data = { +      make_pair(pass1, pass2), +      make_pair(pass2, pass1), +  }; +  for (auto &&  password: data) { +    auto p = get_payload<stick20::ChangeUpdatePassword>(); +    strcpyT(p.current_update_password, password.first); +    strcpyT(p.new_update_password, password.second); +    stick20::ChangeUpdatePassword::CommandTransaction::run(stick, p); +  } +} + +  TEST_CASE("general test", "[test]") {    Stick20 stick;    bool connected = stick.connect();    REQUIRE(connected == true);  | 
