Replace all crypto libraries with Botan
Selected the [Botan crypto library](https://github.com/randombit/botan) due to its feature list, maintainer support, availability across all deployment platforms, and ease of use. Also evaluated Crypto++ as a viable candidate, but the additional features of Botan (PKCS#11, TPM, etc) won out. The random number generator received a backend upgrade. Botan prefers hardware-based RNG's and will provide one if available. This is transparent to KeePassXC and a significant improvement over gcrypt. Replaced Argon2 library with built-in Botan implementation that supports i, d, and id. This requires Botan 2.11.0 or higher. Also simplified the parameter test across KDF's. Aligned SymmetricCipher parameters with available modes. All encrypt and decrypt operations are done in-place instead of returning new objects. This allows use of secure vectors in the future with no additional overhead. Took this opportunity to decouple KeeShare from SSH Agent. Removed leftover code from OpenSSHKey and consolidated the SSH Agent code into the same directory. Removed bcrypt and blowfish inserts since they are provided by Botan. Additionally simplified KeeShare settings interface by removing raw certificate byte data from the user interface. KeeShare will be further refactored in a future PR. NOTE: This PR breaks backwards compatibility with KeeShare certificates due to different RSA key storage with Botan. As a result, new "own" certificates will need to be generated and trust re-established. Removed YKChallengeResponseKeyCLI in favor of just using the original implementation with signal/slots. Removed TestRandom stub since it was just faking random numbers and not actually using the backend. TestRandomGenerator now uses the actual RNG. Greatly simplified Secret Service plugin's use of crypto functions with Botan.
This commit is contained in:
@@ -22,11 +22,13 @@
|
||||
#include "core/Group.h"
|
||||
#include "core/Metadata.h"
|
||||
#include "gui/FileDialog.h"
|
||||
#include "gui/MessageBox.h"
|
||||
#include "keeshare/KeeShare.h"
|
||||
#include "keeshare/KeeShareSettings.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QStandardItemModel>
|
||||
#include <QStandardPaths>
|
||||
#include <QTextStream>
|
||||
|
||||
SettingsWidgetKeeShare::SettingsWidgetKeeShare(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
@@ -72,27 +74,32 @@ void SettingsWidgetKeeShare::updateForeignCertificates()
|
||||
{
|
||||
auto headers = QStringList() << tr("Path") << tr("Status");
|
||||
#if defined(WITH_XC_KEESHARE_SECURE)
|
||||
headers << tr("Signer") << tr("Fingerprint") << tr("Certificate");
|
||||
headers << tr("Signer") << tr("Fingerprint");
|
||||
#endif
|
||||
|
||||
m_importedCertificateModel.reset(new QStandardItemModel());
|
||||
m_importedCertificateModel->setHorizontalHeaderLabels(headers);
|
||||
|
||||
for (const auto& scopedCertificate : m_foreign.certificates) {
|
||||
const auto items = QList<QStandardItem*>()
|
||||
<< new QStandardItem(scopedCertificate.path)
|
||||
<< new QStandardItem(scopedCertificate.trust == KeeShareSettings::Trust::Ask
|
||||
? tr("Ask")
|
||||
: (scopedCertificate.trust == KeeShareSettings::Trust::Trusted
|
||||
? tr("Trusted")
|
||||
: tr("Untrusted")))
|
||||
QList<QStandardItem*> items;
|
||||
items << new QStandardItem(scopedCertificate.path);
|
||||
|
||||
switch (scopedCertificate.trust) {
|
||||
case KeeShareSettings::Trust::Ask:
|
||||
items << new QStandardItem(tr("Ask"));
|
||||
break;
|
||||
case KeeShareSettings::Trust::Trusted:
|
||||
items << new QStandardItem(tr("Trusted"));
|
||||
break;
|
||||
case KeeShareSettings::Trust::Untrusted:
|
||||
items << new QStandardItem(tr("Untrusted"));
|
||||
break;
|
||||
}
|
||||
|
||||
#if defined(WITH_XC_KEESHARE_SECURE)
|
||||
<< new QStandardItem(scopedCertificate.isKnown() ? scopedCertificate.certificate.signer
|
||||
: tr("Unknown"))
|
||||
<< new QStandardItem(scopedCertificate.certificate.fingerprint())
|
||||
<< new QStandardItem(scopedCertificate.certificate.publicKey())
|
||||
items << new QStandardItem(scopedCertificate.isKnown() ? scopedCertificate.certificate.signer : tr("Unknown"));
|
||||
items << new QStandardItem(scopedCertificate.certificate.fingerprint());
|
||||
#endif
|
||||
;
|
||||
m_importedCertificateModel->appendRow(items);
|
||||
}
|
||||
|
||||
@@ -103,8 +110,6 @@ void SettingsWidgetKeeShare::updateForeignCertificates()
|
||||
void SettingsWidgetKeeShare::updateOwnCertificate()
|
||||
{
|
||||
m_ui->ownCertificateSignerEdit->setText(m_own.certificate.signer);
|
||||
m_ui->ownCertificatePublicKeyEdit->setText(m_own.certificate.publicKey());
|
||||
m_ui->ownCertificatePrivateKeyEdit->setText(m_own.key.privateKey());
|
||||
m_ui->ownCertificateFingerprintEdit->setText(m_own.certificate.fingerprint());
|
||||
}
|
||||
|
||||
@@ -133,8 +138,6 @@ void SettingsWidgetKeeShare::generateCertificate()
|
||||
{
|
||||
m_own = KeeShareSettings::Own::generate();
|
||||
m_ui->ownCertificateSignerEdit->setText(m_own.certificate.signer);
|
||||
m_ui->ownCertificatePublicKeyEdit->setText(m_own.certificate.publicKey());
|
||||
m_ui->ownCertificatePrivateKeyEdit->setText(m_own.key.privateKey());
|
||||
m_ui->ownCertificateFingerprintEdit->setText(m_own.certificate.fingerprint());
|
||||
}
|
||||
|
||||
@@ -165,16 +168,14 @@ void SettingsWidgetKeeShare::importCertificate()
|
||||
void SettingsWidgetKeeShare::exportCertificate()
|
||||
{
|
||||
if (KeeShare::own() != m_own) {
|
||||
QMessageBox warning;
|
||||
warning.setIcon(QMessageBox::Warning);
|
||||
warning.setWindowTitle(tr("Exporting changed certificate"));
|
||||
warning.setText(tr("The exported certificate is not the same as the one in use. Do you want to export the "
|
||||
"current certificate?"));
|
||||
auto yes = warning.addButton(QMessageBox::StandardButton::Yes);
|
||||
auto no = warning.addButton(QMessageBox::StandardButton::No);
|
||||
warning.setDefaultButton(no);
|
||||
warning.exec();
|
||||
if (warning.clickedButton() != yes) {
|
||||
auto ans = MessageBox::warning(
|
||||
this,
|
||||
tr("Exporting changed certificate"),
|
||||
tr("The exported certificate is not the same as the one in use. Do you want to export the "
|
||||
"current certificate?"),
|
||||
MessageBox::Yes | MessageBox::No,
|
||||
MessageBox::No);
|
||||
if (ans != MessageBox::Yes) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -186,8 +187,7 @@ void SettingsWidgetKeeShare::exportCertificate()
|
||||
const auto filetype = tr("key.share", "Filetype for KeeShare key");
|
||||
const auto filters = QString("%1 (*." + filetype + ");;%2 (*)").arg(tr("KeeShare key file"), tr("All files"));
|
||||
QString filename = QString("%1.%2").arg(m_own.certificate.signer).arg(filetype);
|
||||
filename = fileDialog()->getSaveFileName(
|
||||
this, tr("Select path"), defaultDirPath, filters, nullptr, QFileDialog::Options(0));
|
||||
filename = fileDialog()->getSaveFileName(this, tr("Select path"), defaultDirPath, filters);
|
||||
if (filename.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user