Commit bfadfb38 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Add option to use symmetric encryption only

This option disables the selection of public keys to use for encryption.

GnuPG-bug-id: 5661
parent 09e29d50
......@@ -240,11 +240,14 @@ void CryptoOperationsConfigWidget::setupGui()
mAutoDecryptVerifyCB = new QCheckBox(i18n("Automatically start operation based on input detection for decrypt/verify."));
mTmpDirCB = new QCheckBox(i18n("Create temporary decrypted files in the folder of the encrypted file."));
mTmpDirCB->setToolTip(i18nc("@info", "Set this option to avoid using the users temporary directory."));
mSymmetricOnlyCB = new QCheckBox(i18n("Use symmetric encryption only."));
mSymmetricOnlyCB->setToolTip(i18nc("@info", "Set this option to disable public key encryption."));
fileGrpLay->addWidget(mPGPFileExtCB);
fileGrpLay->addWidget(mAutoDecryptVerifyCB);
fileGrpLay->addWidget(mASCIIArmorCB);
fileGrpLay->addWidget(mTmpDirCB);
fileGrpLay->addWidget(mSymmetricOnlyCB);
auto comboLay = new QGridLayout;
auto chkLabel = new QLabel(i18n("Checksum program to use when creating checksum files:"));
......@@ -283,6 +286,7 @@ void CryptoOperationsConfigWidget::setupGui()
connect(mAutoDecryptVerifyCB, &QCheckBox::toggled, this, &CryptoOperationsConfigWidget::changed);
connect(mASCIIArmorCB, &QCheckBox::toggled, this, &CryptoOperationsConfigWidget::changed);
connect(mTmpDirCB, &QCheckBox::toggled, this, &CryptoOperationsConfigWidget::changed);
connect(mSymmetricOnlyCB, &QCheckBox::toggled, this, &CryptoOperationsConfigWidget::changed);
}
CryptoOperationsConfigWidget::~CryptoOperationsConfigWidget() {}
......@@ -322,6 +326,7 @@ void CryptoOperationsConfigWidget::load()
mAutoDecryptVerifyCB->setChecked(filePrefs.autoDecryptVerify());
mASCIIArmorCB->setChecked(filePrefs.addASCIIArmor());
mTmpDirCB->setChecked(filePrefs.dontUseTmpDir());
mSymmetricOnlyCB->setChecked(filePrefs.symmetricEncryptionOnly());
const std::vector< std::shared_ptr<ChecksumDefinition> > cds = ChecksumDefinition::getChecksumDefinitions();
const std::shared_ptr<ChecksumDefinition> default_cd = ChecksumDefinition::getDefaultChecksumDefinition(cds);
......@@ -369,6 +374,7 @@ void CryptoOperationsConfigWidget::save()
filePrefs.setAutoDecryptVerify(mAutoDecryptVerifyCB->isChecked());
filePrefs.setAddASCIIArmor(mASCIIArmorCB->isChecked());
filePrefs.setDontUseTmpDir(mTmpDirCB->isChecked());
filePrefs.setSymmetricEncryptionOnly(mSymmetricOnlyCB->isChecked());
const int idx = mChecksumDefinitionCB->currentIndex();
if (idx >= 0) {
......
......@@ -28,7 +28,7 @@ class CryptoOperationsConfigWidget : public QWidget
Q_OBJECT
public:
explicit CryptoOperationsConfigWidget(QWidget *parent = nullptr, Qt::WindowFlags f = {});
~CryptoOperationsConfigWidget();
~CryptoOperationsConfigWidget() override;
public Q_SLOTS:
void load();
......@@ -42,12 +42,15 @@ private:
void setupGui();
void setupProfileGui(QBoxLayout *layout);
void applyProfile(const QString &profile);
private:
QCheckBox *mQuickEncryptCB,
*mQuickSignCB,
*mPGPFileExtCB,
*mAutoDecryptVerifyCB,
*mASCIIArmorCB,
*mTmpDirCB;
*mTmpDirCB,
*mSymmetricOnlyCB;
QComboBox *mChecksumDefinitionCB,
*mArchiveDefinitionCB;
QPushButton *mApplyBtn;
......
......@@ -12,6 +12,7 @@
#include "kleopatra_debug.h"
#include "certificatelineedit.h"
#include "fileoperationspreferences.h"
#include "settings.h"
#include "unknownrecipientwidget.h"
......@@ -104,6 +105,7 @@ SignEncryptWidget::SignEncryptWidget(QWidget *parent, bool sigEncExclusive)
const bool haveSecretKeys = !KeyCache::instance()->secretKeys().empty();
const bool havePublicKeys = !KeyCache::instance()->keys().empty();
const bool symmetricOnly = FileOperationsPreferences().symmetricEncryptionOnly();
/* The signature selection */
auto sigLay = new QHBoxLayout;
......@@ -133,8 +135,8 @@ SignEncryptWidget::SignEncryptWidget(QWidget *parent, bool sigEncExclusive)
// Own key
mEncSelfChk = new QCheckBox(i18n("Encrypt for me:"));
mEncSelfChk->setEnabled(haveSecretKeys);
mEncSelfChk->setChecked(haveSecretKeys);
mEncSelfChk->setEnabled(haveSecretKeys && !symmetricOnly);
mEncSelfChk->setChecked(haveSecretKeys && !symmetricOnly);
mSelfSelect = new KeySelectionCombo();
mSelfSelect->setEnabled(mEncSelfChk->isChecked());
recipientGrid->addWidget(mEncSelfChk, 0, 0);
......@@ -142,8 +144,8 @@ SignEncryptWidget::SignEncryptWidget(QWidget *parent, bool sigEncExclusive)
// Checkbox for other keys
mEncOtherChk = new QCheckBox(i18n("Encrypt for others:"));
mEncOtherChk->setEnabled(havePublicKeys);
mEncOtherChk->setChecked(havePublicKeys);
mEncOtherChk->setEnabled(havePublicKeys && !symmetricOnly);
mEncOtherChk->setChecked(havePublicKeys && !symmetricOnly);
recipientGrid->addWidget(mEncOtherChk, 1, 0, Qt::AlignTop);
connect(mEncOtherChk, &QCheckBox::toggled, this,
[this](bool toggled) {
......@@ -181,7 +183,7 @@ SignEncryptWidget::SignEncryptWidget(QWidget *parent, bool sigEncExclusive)
"Additionally to the keys of the recipients you can encrypt your data with a password. "
"Anyone who has the password can read the data without any secret key. "
"Using a password is <b>less secure</b> then public key cryptography. Even if you pick a very strong password."));
mSymmetric->setChecked(!havePublicKeys);
mSymmetric->setChecked(symmetricOnly || !havePublicKeys);
encBoxLay->addWidget(mSymmetric);
// Connect it
......@@ -228,9 +230,10 @@ SignEncryptWidget::SignEncryptWidget(QWidget *parent, bool sigEncExclusive)
this, [this]() {
const bool haveSecretKeys = !KeyCache::instance()->secretKeys().empty();
const bool havePublicKeys = !KeyCache::instance()->keys().empty();
const bool symmetricOnly = FileOperationsPreferences().symmetricEncryptionOnly();
mSigChk->setEnabled(haveSecretKeys);
mEncSelfChk->setEnabled(haveSecretKeys);
mEncOtherChk->setEnabled(havePublicKeys);
mEncSelfChk->setEnabled(haveSecretKeys && !symmetricOnly);
mEncOtherChk->setEnabled(havePublicKeys && !symmetricOnly);
});
loadKeys();
......@@ -591,9 +594,10 @@ void SignEncryptWidget::setEncryptionChecked(bool checked)
if (checked) {
const bool haveSecretKeys = !KeyCache::instance()->secretKeys().empty();
const bool havePublicKeys = !KeyCache::instance()->keys().empty();
mEncSelfChk->setChecked(haveSecretKeys);
mEncOtherChk->setChecked(havePublicKeys);
mSymmetric->setChecked(!havePublicKeys);
const bool symmetricOnly = FileOperationsPreferences().symmetricEncryptionOnly();
mEncSelfChk->setChecked(haveSecretKeys && !symmetricOnly);
mEncOtherChk->setChecked(havePublicKeys && !symmetricOnly);
mSymmetric->setChecked(symmetricOnly || !havePublicKeys);
} else {
mEncSelfChk->setChecked(false);
mEncOtherChk->setChecked(false);
......
......@@ -31,5 +31,10 @@
<whatsthis>Set this option to avoid using the users temporary directory.</whatsthis>
<default>false</default>
</entry>
<entry name="SymmetricEncryptionOnly" key="symmetric-encryption-only" type="Bool">
<label>Use symmetric encryption only.</label>
<whatsthis>Set this option to disable public key encryption.</whatsthis>
<default>false</default>
</entry>
</group>
</kcfg>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment