diff --git a/src/gui/ChangeMasterKeyWidget.cpp b/src/gui/ChangeMasterKeyWidget.cpp
index 3e346bc10..c69cf2dcc 100644
--- a/src/gui/ChangeMasterKeyWidget.cpp
+++ b/src/gui/ChangeMasterKeyWidget.cpp
@@ -15,14 +15,18 @@
* along with this program. If not, see .
*/
+#include
+
#include "ChangeMasterKeyWidget.h"
#include "ui_ChangeMasterKeyWidget.h"
#include "core/FilePath.h"
#include "keys/FileKey.h"
#include "keys/PasswordKey.h"
+#include "keys/YkChallengeResponseKey.h"
#include "gui/FileDialog.h"
#include "gui/MessageBox.h"
+#include "crypto/Random.h"
ChangeMasterKeyWidget::ChangeMasterKeyWidget(QWidget* parent)
: DialogyWidget(parent)
@@ -81,6 +85,15 @@ void ChangeMasterKeyWidget::clearForms()
m_ui->togglePasswordButton->setChecked(false);
// TODO: clear m_ui->keyFileCombo
+ m_ui->challengeResponseGroup->setChecked(false);
+ m_ui->challengeResponseCombo->clear();
+
+ /* YubiKey init is slow */
+ connect(YubiKey::instance(), SIGNAL(detected(int,bool)),
+ SLOT(ykDetected(int,bool)),
+ Qt::QueuedConnection);
+ QtConcurrent::run(YubiKey::instance(), &YubiKey::detect);
+
m_ui->enterPasswordEdit->setFocus();
}
@@ -128,6 +141,14 @@ void ChangeMasterKeyWidget::generateKey()
m_key.addKey(fileKey);
}
+ if (m_ui->challengeResponseGroup->isChecked()) {
+ int i = m_ui->challengeResponseCombo->currentIndex();
+ i = m_ui->challengeResponseCombo->itemData(i).toInt();
+ YkChallengeResponseKey key(i);
+
+ m_key.addChallengeResponseKey(key);
+ }
+
Q_EMIT editFinished(true);
}
@@ -136,3 +157,11 @@ void ChangeMasterKeyWidget::reject()
{
Q_EMIT editFinished(false);
}
+
+
+void ChangeMasterKeyWidget::ykDetected(int slot, bool blocking)
+{
+ YkChallengeResponseKey yk(slot, blocking);
+ m_ui->challengeResponseCombo->addItem(yk.getName(), QVariant(slot));
+ m_ui->challengeResponseGroup->setEnabled(true);
+}
diff --git a/src/gui/ChangeMasterKeyWidget.h b/src/gui/ChangeMasterKeyWidget.h
index 8985ff7a8..9b765c205 100644
--- a/src/gui/ChangeMasterKeyWidget.h
+++ b/src/gui/ChangeMasterKeyWidget.h
@@ -47,6 +47,7 @@ private Q_SLOTS:
void reject();
void createKeyFile();
void browseKeyFile();
+ void ykDetected(int slot, bool blocking);
private:
const QScopedPointer m_ui;
diff --git a/src/gui/ChangeMasterKeyWidget.ui b/src/gui/ChangeMasterKeyWidget.ui
index d14941ccc..335a67c92 100644
--- a/src/gui/ChangeMasterKeyWidget.ui
+++ b/src/gui/ChangeMasterKeyWidget.ui
@@ -123,6 +123,31 @@
+ -
+
+
+ false
+
+
+ Challenge Response
+
+
+ true
+
+
+
-
+
+
+ -
+
+
+ Challenge Response:
+
+
+
+
+
+
-
diff --git a/src/gui/DatabaseOpenWidget.cpp b/src/gui/DatabaseOpenWidget.cpp
index 781b836fd..5d3815963 100644
--- a/src/gui/DatabaseOpenWidget.cpp
+++ b/src/gui/DatabaseOpenWidget.cpp
@@ -15,6 +15,8 @@
* along with this program. If not, see .
*/
+#include
+
#include "DatabaseOpenWidget.h"
#include "ui_DatabaseOpenWidget.h"
@@ -27,6 +29,9 @@
#include "format/KeePass2Reader.h"
#include "keys/FileKey.h"
#include "keys/PasswordKey.h"
+#include "keys/YkChallengeResponseKey.h"
+#include "crypto/Random.h"
+
DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent)
: DialogyWidget(parent)
@@ -49,6 +54,13 @@ DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent)
connect(m_ui->editPassword, SIGNAL(textChanged(QString)), SLOT(activatePassword()));
connect(m_ui->comboKeyFile, SIGNAL(editTextChanged(QString)), SLOT(activateKeyFile()));
+ connect(m_ui->comboChallengeResponse, SIGNAL(activated(int)), SLOT(activateChallengeResponse()));
+
+ connect(m_ui->checkPassword, SIGNAL(toggled(bool)), SLOT(setOkButtonEnabled()));
+ connect(m_ui->checkKeyFile, SIGNAL(toggled(bool)), SLOT(setOkButtonEnabled()));
+ connect(m_ui->comboKeyFile, SIGNAL(editTextChanged(QString)), SLOT(setOkButtonEnabled()));
+ connect(m_ui->checkChallengeResponse, SIGNAL(toggled(bool)), SLOT(setOkButtonEnabled()));
+ connect(m_ui->comboChallengeResponse, SIGNAL(activated(int)), SLOT(setOkButtonEnabled()));
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(openDatabase()));
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject()));
@@ -79,6 +91,13 @@ void DatabaseOpenWidget::load(const QString& filename)
}
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
+
+ /* YubiKey init is slow */
+ connect(YubiKey::instance(), SIGNAL(detected(int,bool)),
+ SLOT(ykDetected(int,bool)),
+ Qt::QueuedConnection);
+ QtConcurrent::run(YubiKey::instance(), &YubiKey::detect);
+
m_ui->editPassword->setFocus();
}
@@ -156,6 +175,15 @@ CompositeKey DatabaseOpenWidget::databaseKey()
config()->set("LastKeyFiles", lastKeyFiles);
}
+
+ if (m_ui->checkChallengeResponse->isChecked()) {
+ int i = m_ui->comboChallengeResponse->currentIndex();
+ i = m_ui->comboChallengeResponse->itemData(i).toInt();
+ YkChallengeResponseKey key(i);
+
+ masterKey.addChallengeResponseKey(key);
+ }
+
return masterKey;
}
@@ -174,6 +202,19 @@ void DatabaseOpenWidget::activateKeyFile()
m_ui->checkKeyFile->setChecked(true);
}
+void DatabaseOpenWidget::activateChallengeResponse()
+{
+ m_ui->checkChallengeResponse->setChecked(true);
+}
+
+void DatabaseOpenWidget::setOkButtonEnabled()
+{
+ bool enable = m_ui->checkPassword->isChecked() || m_ui->checkChallengeResponse->isChecked()
+ || (m_ui->checkKeyFile->isChecked() && !m_ui->comboKeyFile->currentText().isEmpty());
+
+ m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(enable);
+}
+
void DatabaseOpenWidget::browseKeyFile()
{
QString filters = QString("%1 (*);;%2 (*.key)").arg(tr("All files"), tr("Key files"));
@@ -183,3 +224,11 @@ void DatabaseOpenWidget::browseKeyFile()
m_ui->comboKeyFile->lineEdit()->setText(filename);
}
}
+
+void DatabaseOpenWidget::ykDetected(int slot, bool blocking)
+{
+ YkChallengeResponseKey yk(slot, blocking);
+ m_ui->comboChallengeResponse->addItem(yk.getName(), QVariant(slot));
+ m_ui->comboChallengeResponse->setEnabled(true);
+ m_ui->checkChallengeResponse->setEnabled(true);
+}
diff --git a/src/gui/DatabaseOpenWidget.h b/src/gui/DatabaseOpenWidget.h
index 34f401a09..fadb5ee70 100644
--- a/src/gui/DatabaseOpenWidget.h
+++ b/src/gui/DatabaseOpenWidget.h
@@ -55,7 +55,10 @@ protected Q_SLOTS:
private Q_SLOTS:
void activatePassword();
void activateKeyFile();
+ void activateChallengeResponse();
+ void setOkButtonEnabled();
void browseKeyFile();
+ void ykDetected(int slot, bool blocking);
protected:
const QScopedPointer m_ui;
diff --git a/src/gui/DatabaseOpenWidget.ui b/src/gui/DatabaseOpenWidget.ui
index 4aae5faf2..3d651ee8d 100644
--- a/src/gui/DatabaseOpenWidget.ui
+++ b/src/gui/DatabaseOpenWidget.ui
@@ -111,6 +111,23 @@
+ -
+
+
+ false
+
+
+ Challenge Response:
+
+
+
+ -
+
+
+ false
+
+
+
-