Skip to content

Commit

Permalink
Command "destroy encrypted data" do not initialize the storage with r…
Browse files Browse the repository at this point in the history
…andom data (#63)

Closes issue #45
  • Loading branch information
szszszsz committed May 16, 2016
1 parent 302dadb commit 08f7744
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions src/ui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1136,13 +1136,21 @@ void MainWindow::initActionsForStick20() {
connect(Stick20ActionExportFirmwareToFile, SIGNAL(triggered()), this,
SLOT(startStick20ExportFirmwareToFile()));

QSignalMapper *signalMapper_startStick20DestroyCryptedVolume =
new QSignalMapper(this); // FIXME memory leak

Stick20ActionDestroyCryptedVolume = new QAction(tr("&Destroy encrypted data"), this);
connect(Stick20ActionDestroyCryptedVolume, SIGNAL(triggered()), this,
SLOT(startStick20DestroyCryptedVolume()));
signalMapper_startStick20DestroyCryptedVolume->setMapping(Stick20ActionDestroyCryptedVolume, 0);
connect(Stick20ActionDestroyCryptedVolume, SIGNAL(triggered()),
signalMapper_startStick20DestroyCryptedVolume, SLOT(map()));

Stick20ActionInitCryptedVolume = new QAction(tr("&Initialize device"), this);
connect(Stick20ActionInitCryptedVolume, SIGNAL(triggered()), this,
SLOT(startStick20DestroyCryptedVolume()));
signalMapper_startStick20DestroyCryptedVolume->setMapping(Stick20ActionInitCryptedVolume, 1);
connect(Stick20ActionInitCryptedVolume, SIGNAL(triggered()),
signalMapper_startStick20DestroyCryptedVolume, SLOT(map()));

connect(signalMapper_startStick20DestroyCryptedVolume, SIGNAL(mapped(int)), this,
SLOT(startStick20DestroyCryptedVolume(int)));

Stick20ActionFillSDCardWithRandomChars =
new QAction(tr("&Initialize storage with random data"), this);
Expand Down Expand Up @@ -2502,7 +2510,7 @@ void MainWindow::startStick20ExportFirmwareToFile() {
}
}

void MainWindow::startStick20DestroyCryptedVolume() {
void MainWindow::startStick20DestroyCryptedVolume(int fillSDWithRandomChars) {
uint8_t password[LOCAL_PASSWORD_SIZE];

int ret;
Expand All @@ -2522,7 +2530,8 @@ void MainWindow::startStick20DestroyCryptedVolume() {
dialog.getPassword((char *)password);

stick20SendCommand(STICK20_CMD_GENERATE_NEW_KEYS, password);
stick20SendCommand(STICK20_CMD_FILL_SD_CARD_WITH_RANDOM_CHARS, password);
if (fillSDWithRandomChars != 0)
stick20SendCommand(STICK20_CMD_FILL_SD_CARD_WITH_RANDOM_CHARS, password);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public slots:
void getTOTPDialog(int slot);
void getHOTPDialog(int slot);
void PWS_ExceClickedSlot(int Slot);
void startStick20DestroyCryptedVolume();
void startStick20DestroyCryptedVolume(int fillSDWithRandomChars);
void startStick20FillSDCardWithRandomChars();
void startStick20EnableCryptedVolume();
void startStick20DisableCryptedVolume();
Expand Down

0 comments on commit 08f7744

Please sign in to comment.