diff options
Diffstat (limited to '')
-rw-r--r-- | include/gpg/GpgContext.h | 17 | ||||
-rw-r--r-- | include/gpg/GpgGenKeyInfo.h | 31 | ||||
-rw-r--r-- | include/gpg/GpgKey.h | 79 | ||||
-rw-r--r-- | include/gpg/GpgSubKey.h | 57 | ||||
-rw-r--r-- | include/ui/KeyList.h | 2 | ||||
-rwxr-xr-x | include/ui/KeyMgmt.h | 6 | ||||
-rw-r--r-- | include/ui/KeygenDialog.h | 15 | ||||
-rw-r--r-- | src/gpg/GpgContext.cpp | 27 | ||||
-rw-r--r-- | src/gpg/GpgKey.cpp | 5 | ||||
-rw-r--r-- | src/gpg/GpgSubKey.cpp | 5 | ||||
-rw-r--r-- | src/ui/KeyList.cpp | 46 | ||||
-rwxr-xr-x | src/ui/KeyMgmt.cpp | 34 | ||||
-rw-r--r-- | src/ui/KeygenDialog.cpp | 73 |
13 files changed, 250 insertions, 147 deletions
diff --git a/include/gpg/GpgContext.h b/include/gpg/GpgContext.h index d6117d8a..071fff8b 100644 --- a/include/gpg/GpgContext.h +++ b/include/gpg/GpgContext.h @@ -29,22 +29,7 @@ #include "GpgConstants.h" #include "GpgGenKeyInfo.h" - - -class GpgKey { -public: - GpgKey() { - privkey = false; - } - - QString id; - QString name; - QString email; - QString fpr; - bool privkey; - bool expired{}; - bool revoked{}; -}; +#include "GpgKey.h" typedef QLinkedList<GpgKey> GpgKeyList; diff --git a/include/gpg/GpgGenKeyInfo.h b/include/gpg/GpgGenKeyInfo.h index dc5ae0e9..f4273b05 100644 --- a/include/gpg/GpgGenKeyInfo.h +++ b/include/gpg/GpgGenKeyInfo.h @@ -48,7 +48,7 @@ class GenKeyInfo { public: - static const QVector<QString> SupportedAlgo; + static const QVector<QString> SupportedKeyAlgo; [[nodiscard]] bool isSubKey() const { return subKey; @@ -103,32 +103,45 @@ public: */ setAllowEncryption(false); allowChangeEncryption = false; - setAllowAuthentication(false); - allowChangeAuthentication = false; suggestMinKeySize = 1024; suggestMaxKeySize = 3072; suggestSizeAdditionStep = 1024; setKeySize(2048); - } else if (lower_algo == "elg") { + } else if (lower_algo == "ed25519") { /** * GnuPG supports the Elgamal asymmetric encryption algorithm in key lengths ranging from 1024 to 4096 bits. */ - suggestMinKeySize = 1024; - suggestMaxKeySize = 4096; - suggestSizeAdditionStep = 1024; - setKeySize(2048); + + setAllowEncryption(false); + allowChangeEncryption = false; + + suggestMinKeySize = -1; + suggestMaxKeySize = -1; + suggestSizeAdditionStep = -1; + setKeySize(-1); } GenKeyInfo::algo = lower_algo; } + [[nodiscard]] QString getKeySizeStr() const { + if(keySize > 0) { + return QString::number(keySize); + } + else { + return QString(); + } + + } + [[nodiscard]] int getKeySize() const { return keySize; + } void setKeySize(int m_key_size) { - if (m_key_size < 0 || m_key_size > 8192) { + if (m_key_size < suggestMinKeySize || m_key_size > suggestMaxKeySize) { return; } GenKeyInfo::keySize = m_key_size; diff --git a/include/gpg/GpgKey.h b/include/gpg/GpgKey.h new file mode 100644 index 00000000..d33bd71d --- /dev/null +++ b/include/gpg/GpgKey.h @@ -0,0 +1,79 @@ +// +// Created by eric on 2021/5/21. +// + +#ifndef GPGFRONTEND_GPGKEY_H +#define GPGFRONTEND_GPGKEY_H + +#include <gpgme.h> + +#include "GpgSubKey.h" + +class GpgKey { +public: + GpgKey() { + is_private_key = false; + } + + QString id; + QString name; + QString email; + QString fpr; + QString protocol; + int owner_trust; + QDateTime last_update; + + bool can_encrypt{}; + bool can_sign{}; + bool can_certify{}; + bool can_authenticate{}; + + + bool is_private_key{}; + bool expired{}; + bool revoked{}; + bool disabled{}; + + QVector<GpgSubKey> subKeys; + + GpgKey(gpgme_key_t key) { + is_private_key = key->secret; + fpr = key->fpr; + protocol = key->protocol; + expired = (key->expired != 0u); + revoked = (key->revoked != 0u); + + disabled = key->disabled; + + can_authenticate = key->can_authenticate; + can_certify = key->can_certify; + can_encrypt = key->can_encrypt; + can_sign = key->can_sign; + + last_update = QDateTime(QDateTime::fromTime_t(key->last_update)); + owner_trust = key->owner_trust; + + if (key->uids) { + name = QString::fromUtf8(key->uids->name); + email = QString::fromUtf8(key->uids->email); + } + + gpgme_subkey_t next = key->subkeys; + + while(next != nullptr) { + subKeys.push_back(GpgSubKey(next)); + next = next->next; + } + + if(!subKeys.isEmpty()) { + id = subKeys.first().id; + } else { + id = ""; + } + + + } +}; + + +#endif //GPGFRONTEND_GPGKEY_H diff --git a/include/gpg/GpgSubKey.h b/include/gpg/GpgSubKey.h new file mode 100644 index 00000000..1c810693 --- /dev/null +++ b/include/gpg/GpgSubKey.h @@ -0,0 +1,57 @@ +// +// Created by eric on 2021/5/21. +// + +#ifndef GPGFRONTEND_GPGSUBKEY_H +#define GPGFRONTEND_GPGSUBKEY_H + + +#include <gpgme.h> + +struct GpgSubKey { + + QString id; + QString fpr; + + bool can_encrypt{}; + bool can_sign{}; + bool can_certify{}; + bool can_authenticate{}; + + + bool is_private_key{}; + bool expired{}; + bool revoked{}; + bool disabled{}; + bool is_cardkey{}; + + QDateTime timestamp; + QDateTime expires; + + GpgSubKey() = default; + + explicit GpgSubKey(gpgme_subkey_t key) { + + id = key->keyid; + fpr = key->fpr; + + expired = (key->expired != 0u); + revoked = (key->revoked != 0u); + + disabled = key->disabled; + + can_authenticate = key->can_authenticate; + can_certify = key->can_certify; + can_encrypt = key->can_encrypt; + can_sign = key->can_sign; + is_cardkey = key->is_cardkey; + is_private_key = key->secret; + + timestamp = QDateTime::fromTime_t(key->timestamp); + expires = QDateTime::fromTime_t(key->expires); + } + +}; + + +#endif //GPGFRONTEND_GPGSUBKEY_H diff --git a/include/ui/KeyList.h b/include/ui/KeyList.h index ed555ca8..71bdfe6b 100644 --- a/include/ui/KeyList.h +++ b/include/ui/KeyList.h @@ -68,6 +68,8 @@ private: QMenu *popupMenu; QNetworkAccessManager *qnam{}; + QVector<GpgKey> buffered_keys; + private slots: void uploadFinished(); diff --git a/include/ui/KeyMgmt.h b/include/ui/KeyMgmt.h index 5b6f7695..e3f438c2 100755 --- a/include/ui/KeyMgmt.h +++ b/include/ui/KeyMgmt.h @@ -43,8 +43,13 @@ public: QAction *importKeyFromFileAct{}; QAction *importKeyFromKeyServerAct{}; + QAction *generateKeyPairAct{}; + QAction *generateSubKeyAct{}; + public slots: + void slotGenerateSubKey(); + void slotImportKeyFromFile(); void slotImportKeyFromClipboard(); @@ -82,6 +87,7 @@ private: GpgME::GpgContext *mCtx; QMenu *fileMenu{}; QMenu *keyMenu{}; + QMenu *generateKeyMenu{}; QMenu *importKeyMenu{}; QAction *exportKeyToFileAct{}; QAction *exportKeyToClipboardAct{}; diff --git a/include/ui/KeygenDialog.h b/include/ui/KeygenDialog.h index 34dfeda1..08193fd5 100644 --- a/include/ui/KeygenDialog.h +++ b/include/ui/KeygenDialog.h @@ -61,14 +61,11 @@ private: QLineEdit *nameEdit{}; /** Lineedit for the keys name */ QLineEdit *emailEdit{}; /** Lineedit for the keys email */ QLineEdit *commentEdit{}; /** Lineedit for the keys comment */ - QLineEdit *passwordEdit{}; /** Lineedit for the keys password */ - QLineEdit *repeatpwEdit{}; /** Lineedit for the repetition of the keys password */ QSpinBox *keySizeSpinBox{}; /** Spinbox for the keys size (in bit) */ QComboBox *keyTypeComboBox{}; /** Combobox for Keytpe */ QDateTimeEdit *dateEdit{}; /** Dateedit for expiration date */ QCheckBox *expireCheckBox{}; /** Checkbox, if key should expire */ QCheckBox *noPassPhraseCheckBox{}; - QSlider *pwStrengthSlider{}; /** Slider showing the password strength */ QGroupBox *keyUsageGroupBox{}; /** Group of Widgets detecting the usage of the Key **/ @@ -79,13 +76,6 @@ private: void generateKeyDialog(); - /** - * @details Check the password strength of the text in the passwordEdit member - * - * @return digit between 0 and 6, the higher the more secure is the password - */ - int checkPassWordStrength(); - /** * @details Refresh widgets state by GenKeyInfo @@ -104,11 +94,6 @@ private slots: void slotExpireBoxChanged(); /** - * @details When passwordedit changed, set new value for password strength slider - */ - void slotPasswordEditChanged(); - - /** * @details check all lineedits for false entries. Show error, when there is one, otherwise generate the key */ void slotKeyGenAccept(); diff --git a/src/gpg/GpgContext.cpp b/src/gpg/GpgContext.cpp index d4a523cc..a423cfbf 100644 --- a/src/gpg/GpgContext.cpp +++ b/src/gpg/GpgContext.cpp @@ -31,10 +31,10 @@ #include <windows.h> #endif -const QVector<QString> GenKeyInfo::SupportedAlgo = { +const QVector<QString> GenKeyInfo::SupportedKeyAlgo = { "RSA", "DSA", - "ELG" + "ED25519" }; namespace GpgME { @@ -190,7 +190,7 @@ namespace GpgME { auto userid_utf8 = params->getUserid().toUtf8(); const char *userid = userid_utf8.constData(); - auto algo_utf8 = (params->getAlgo() + QString::number(params->getKeySize())).toUtf8(); + auto algo_utf8 = (params->getAlgo() + params->getKeySizeStr()).toUtf8(); const char *algo = algo_utf8.constData(); unsigned long expires = params->getExpired().toTime_t(); unsigned int flags = 0; @@ -280,24 +280,15 @@ namespace GpgME { GpgKeyList keys; //TODO dont run the loop more often than necessary // list all keys ( the 0 is for all ) + gpgmeError = gpgme_set_keylist_mode(mCtx, GPGME_KEYLIST_MODE_LOCAL | GPGME_KEYLIST_MODE_WITH_SECRET); + checkErr(gpgmeError); gpgmeError = gpgme_op_keylist_start(mCtx, nullptr, 0); checkErr(gpgmeError); while (!(gpgmeError = gpgme_op_keylist_next(mCtx, &key))) { - GpgKey gpgkey; - if (!key->subkeys) continue; - gpgkey.id = key->subkeys->keyid; - gpgkey.fpr = key->subkeys->fpr; - gpgkey.expired = (key->expired != 0u); - gpgkey.revoked = (key->revoked != 0u); - - if (key->uids) { - gpgkey.name = QString::fromUtf8(key->uids->name); - gpgkey.email = QString::fromUtf8(key->uids->email); - } - keys.append(gpgkey); + keys.append(GpgKey(key)); gpgme_key_unref(key); } gpgme_op_keylist_end(mCtx); @@ -311,7 +302,7 @@ namespace GpgME { GpgKeyList::iterator it = keys.begin(); while (it != keys.end()) { if (key->subkeys->keyid == it->id.toStdString()) - it->privkey = true; + it->is_private_key = true; it++; } @@ -807,7 +798,7 @@ namespace GpgME { } /** - * note: privkey status is not returned + * note: is_private_key status is not returned */ GpgKey GpgContext::getKeyByFpr(const QString& fpr) { @@ -822,7 +813,7 @@ namespace GpgME { } /** - * note: privkey status is not returned + * note: is_private_key status is not returned */ GpgKey GpgContext::getKeyById(const QString& id) { diff --git a/src/gpg/GpgKey.cpp b/src/gpg/GpgKey.cpp new file mode 100644 index 00000000..c2454807 --- /dev/null +++ b/src/gpg/GpgKey.cpp @@ -0,0 +1,5 @@ +// +// Created by eric on 2021/5/21. +// + +#include "gpg/GpgKey.h" diff --git a/src/gpg/GpgSubKey.cpp b/src/gpg/GpgSubKey.cpp new file mode 100644 index 00000000..6b0ee3ca --- /dev/null +++ b/src/gpg/GpgSubKey.cpp @@ -0,0 +1,5 @@ +// +// Created by eric on 2021/5/21. +// + +#include "gpg/GpgSubKey.h" diff --git a/src/ui/KeyList.cpp b/src/ui/KeyList.cpp index fa35d882..ab812b22 100644 --- a/src/ui/KeyList.cpp +++ b/src/ui/KeyList.cpp @@ -32,16 +32,12 @@ KeyList::KeyList(GpgME::GpgContext *ctx, QWidget *parent) mCtx = ctx; mKeyList = new QTableWidget(this); - mKeyList->setColumnCount(6); + mKeyList->setColumnCount(7); + mKeyList->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); mKeyList->verticalHeader()->hide(); mKeyList->setShowGrid(false); - mKeyList->setColumnWidth(0, 24); - mKeyList->setColumnWidth(1, 20); mKeyList->sortByColumn(2, Qt::AscendingOrder); mKeyList->setSelectionBehavior(QAbstractItemView::SelectRows); - // hide id and fingerprint of key - mKeyList->setColumnHidden(4, true); - mKeyList->setColumnHidden(5, true); // tableitems not editable mKeyList->setEditTriggers(QAbstractItemView::NoEditTriggers); @@ -52,7 +48,8 @@ KeyList::KeyList(GpgME::GpgContext *ctx, QWidget *parent) mKeyList->setAlternatingRowColors(true); QStringList labels; - labels << "" << "" << tr("Name") << tr("EMail") << "id" << "fpr"; + labels << "" << tr("Type") << tr("Name") << tr("Email Address") + << tr("Usage") << tr("Validity") << tr("Finger Print"); mKeyList->setHorizontalHeaderLabels(labels); mKeyList->horizontalHeader()->setStretchLastSection(true); @@ -81,17 +78,25 @@ void KeyList::slotRefresh() int row = 0; GpgKeyList::iterator it = keys.begin(); + buffered_keys.clear(); + while (it != keys.end()) { + buffered_keys.push_back(*it); + auto *tmp0 = new QTableWidgetItem(); tmp0->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); tmp0->setCheckState(Qt::Unchecked); mKeyList->setItem(row, 0, tmp0); - if (it->privkey) { - auto *tmp1 = new QTableWidgetItem(QIcon(":kgpg_key2.png"), ""); + if (it->is_private_key) { + auto *tmp1 = new QTableWidgetItem("pub/sec"); + mKeyList->setItem(row, 1, tmp1); + } else { + auto *tmp1 = new QTableWidgetItem("pub"); mKeyList->setItem(row, 1, tmp1); } + auto *tmp2 = new QTableWidgetItem(it->name); tmp2->setToolTip(it->name); mKeyList->setItem(row, 2, tmp2); @@ -105,10 +110,23 @@ void KeyList::slotRefresh() tmp3->setFont(strike); } mKeyList->setItem(row, 3, tmp3); - auto *tmp4 = new QTableWidgetItem(it->id); - mKeyList->setItem(row, 4, tmp4); - auto *tmp5 = new QTableWidgetItem(it->fpr); - mKeyList->setItem(row, 5, tmp5); + + QString usage; + QTextStream usage_steam(&usage); + + if(it->can_certify) + usage_steam << "C"; + if(it->can_encrypt) + usage_steam << "E"; + if(it->can_sign) + usage_steam << "S"; + if(it->can_authenticate) + usage_steam << "A"; + + auto *temp_usage = new QTableWidgetItem(usage); + mKeyList->setToolTip(usage); + temp_usage->setTextAlignment(Qt::AlignCenter); + mKeyList->setItem(row, 4, temp_usage); it++; @@ -123,7 +141,7 @@ QStringList *KeyList::getChecked() auto *ret = new QStringList(); for (int i = 0; i < mKeyList->rowCount(); i++) { if (mKeyList->item(i, 0)->checkState() == Qt::Checked) { - *ret << mKeyList->item(i, 4)->text(); + *ret << buffered_keys[i].id; } } return ret; diff --git a/src/ui/KeyMgmt.cpp b/src/ui/KeyMgmt.cpp index afaaf308..2904dd0c 100755 --- a/src/ui/KeyMgmt.cpp +++ b/src/ui/KeyMgmt.cpp @@ -75,6 +75,16 @@ void KeyMgmt::createActions() closeAct->setToolTip(tr("Close Key Management")); connect(closeAct, SIGNAL(triggered()), this, SLOT(close())); + generateKeyPairAct = new QAction(tr("Generate KeyPair"), this); + generateKeyPairAct->setIcon(QIcon(":key_generate.png")); + generateKeyPairAct->setToolTip(tr("Generate KeyPair")); + connect(generateKeyPairAct, SIGNAL(triggered()), this, SLOT(slotGenerateKeyDialog())); + + generateSubKeyAct = new QAction(tr("Generate SubKey"), this); + generateSubKeyAct->setIcon(QIcon(":key_generate.png")); + generateSubKeyAct->setToolTip(tr("Generate SubKey Of KeyPair")); + connect(generateSubKeyAct, SIGNAL(triggered()), this, SLOT(slotGenerateSubKey())); + importKeyFromFileAct = new QAction(tr("&File"), this); importKeyFromFileAct->setIcon(QIcon(":import_key_from_file.png")); importKeyFromFileAct->setToolTip(tr("Import New Key From File")); @@ -109,11 +119,6 @@ void KeyMgmt::createActions() deleteCheckedKeysAct->setIcon(QIcon(":button_cancel.png")); connect(deleteCheckedKeysAct, SIGNAL(triggered()), this, SLOT(slotDeleteCheckedKeys())); - generateKeyDialogAct = new QAction(tr("Generate Key"), this); - generateKeyDialogAct->setToolTip(tr("Generate New Key")); - generateKeyDialogAct->setIcon(QIcon(":key_generate.png")); - connect(generateKeyDialogAct, SIGNAL(triggered()), this, SLOT(slotGenerateKeyDialog())); - showKeyDetailsAct = new QAction(tr("Show Keydetails"), this); showKeyDetailsAct->setToolTip(tr("Show Details for this Key")); connect(showKeyDetailsAct, SIGNAL(triggered()), this, SLOT(slotShowKeyDetails())); @@ -125,6 +130,10 @@ void KeyMgmt::createMenus() fileMenu->addAction(closeAct); keyMenu = menuBar()->addMenu(tr("&Key")); + generateKeyMenu = keyMenu->addMenu(tr("&Generate Key")); + generateKeyMenu->addAction(generateKeyPairAct); + generateKeyMenu->addAction(generateSubKeyAct); + importKeyMenu = keyMenu->addMenu(tr("&Import Key From...")); importKeyMenu->addAction(importKeyFromFileAct); importKeyMenu->addAction(importKeyFromClipboardAct); @@ -133,7 +142,6 @@ void KeyMgmt::createMenus() keyMenu->addAction(exportKeyToClipboardAct); keyMenu->addSeparator(); keyMenu->addAction(deleteCheckedKeysAct); - keyMenu->addAction(generateKeyDialogAct); } void KeyMgmt::createToolBars() @@ -142,6 +150,16 @@ void KeyMgmt::createToolBars() keyToolBar->setObjectName("keytoolbar"); // add button with popup menu for import + auto* generateToolButton = new QToolButton(this); + generateToolButton->setMenu(generateKeyMenu); + generateToolButton->setPopupMode(QToolButton::InstantPopup); + generateToolButton->setIcon(QIcon(":key_generate.png")); + generateToolButton->setToolTip(tr("Generate key")); + generateToolButton->setText(tr("Generate key")); + generateToolButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); + keyToolBar->addWidget(generateToolButton); + + // add button with popup menu for import auto* toolButton = new QToolButton(this); toolButton->setMenu(importKeyMenu); toolButton->setPopupMode(QToolButton::InstantPopup); @@ -291,3 +309,7 @@ void KeyMgmt::closeEvent(QCloseEvent *event) QMainWindow::closeEvent(event); } + +void KeyMgmt::slotGenerateSubKey() { + +} diff --git a/src/ui/KeygenDialog.cpp b/src/ui/KeygenDialog.cpp index 6296f8b8..1ebe45f3 100644 --- a/src/ui/KeygenDialog.cpp +++ b/src/ui/KeygenDialog.cpp @@ -44,10 +44,10 @@ void KeyGenDialog::generateKeyDialog() { keySizeSpinBox = new QSpinBox(this); keyTypeComboBox = new QComboBox(this); - for(auto &algo : GenKeyInfo::SupportedAlgo) { + for(auto &algo : GenKeyInfo::SupportedKeyAlgo) { keyTypeComboBox->addItem(algo); } - if(!GenKeyInfo::SupportedAlgo.isEmpty()) { + if(!GenKeyInfo::SupportedKeyAlgo.isEmpty()) { keyTypeComboBox->setCurrentIndex(0); } @@ -63,22 +63,9 @@ void KeyGenDialog::generateKeyDialog() { expireCheckBox = new QCheckBox(this); expireCheckBox->setCheckState(Qt::Unchecked); - passwordEdit = new QLineEdit(this); - repeatpwEdit = new QLineEdit(this); - - passwordEdit->setEchoMode(QLineEdit::Password); - repeatpwEdit->setEchoMode(QLineEdit::Password); - noPassPhraseCheckBox = new QCheckBox(this); noPassPhraseCheckBox->setCheckState(Qt::Unchecked); - pwStrengthSlider = new QSlider(this); - pwStrengthSlider->setOrientation(Qt::Horizontal); - pwStrengthSlider->setMaximum(6); - pwStrengthSlider->setDisabled(true); - pwStrengthSlider->setToolTip(tr("Password Strength")); - pwStrengthSlider->setTickPosition(QSlider::TicksBelow); - auto *vbox1 = new QGridLayout; vbox1->addWidget(new QLabel(tr("Name:")), 0, 0); @@ -88,10 +75,7 @@ void KeyGenDialog::generateKeyDialog() { vbox1->addWidget(new QLabel(tr("Never Expire")), 3, 3); vbox1->addWidget(new QLabel(tr("KeySize (in Bit):")), 4, 0); vbox1->addWidget(new QLabel(tr("Key Type:")), 5, 0); - vbox1->addWidget(new QLabel(tr("Non Pass Phrase")), 6, 3); - vbox1->addWidget(new QLabel(tr("Pass Phrase:")), 6, 0); - vbox1->addWidget(new QLabel(tr("Pass Phrase: Strength\nWeak -> Strong")), 7, 3); - vbox1->addWidget(new QLabel(tr("Repeat Pass Phrase:")), 7, 0); + vbox1->addWidget(new QLabel(tr("Non Pass Phrase")), 6, 0); vbox1->addWidget(nameEdit, 0, 1, 1, 3); vbox1->addWidget(emailEdit, 1, 1, 1, 3); @@ -100,10 +84,7 @@ void KeyGenDialog::generateKeyDialog() { vbox1->addWidget(expireCheckBox, 3, 2); vbox1->addWidget(keySizeSpinBox, 4, 1); vbox1->addWidget(keyTypeComboBox, 5, 1); - vbox1->addWidget(noPassPhraseCheckBox, 6, 2); - vbox1->addWidget(passwordEdit, 6, 1); - vbox1->addWidget(repeatpwEdit, 7, 1); - vbox1->addWidget(pwStrengthSlider, 8, 3); + vbox1->addWidget(noPassPhraseCheckBox, 6, 1); auto *groupGrid = new QGridLayout(this); groupGrid->addLayout(vbox1, 0, 0); @@ -136,9 +117,6 @@ void KeyGenDialog::slotKeyGenAccept() { } if(emailEdit->text().isEmpty() || !check_email_address(emailEdit->text())) { errorString.append(tr(" Please give a email address. \n")); } - if (passwordEdit->text() != repeatpwEdit->text()) { - errorString.append(tr(" Password and Repeat don't match. ")); - } /** * primary keys should have a reasonable expiration date (no more than 2 years in the future) @@ -157,8 +135,6 @@ void KeyGenDialog::slotKeyGenAccept() { genKeyInfo.setKeySize(keySizeSpinBox->value()); - genKeyInfo.setPassPhrase(passwordEdit->text()); - if (expireCheckBox->checkState()) { genKeyInfo.setNonExpired(true); } else { @@ -217,42 +193,6 @@ void KeyGenDialog::slotExpireBoxChanged() { } } -void KeyGenDialog::slotPasswordEditChanged() { - pwStrengthSlider->setValue(checkPassWordStrength()); - update(); -} - -int KeyGenDialog::checkPassWordStrength() { - int strength = 0; - - // increase strength by two, if password has more than 7 characters - if ((passwordEdit->text()).length() > 7) { - strength = strength + 2; - } - - // increase strength by one, if password contains a digit - if ((passwordEdit->text()).contains(QRegExp("\\d"))) { - strength++; - } - - // increase strength by one, if password contains a lowercase character - if ((passwordEdit->text()).contains(QRegExp("[a-z]"))) { - strength++; - } - - // increase strength by one, if password contains an uppercase character - if ((passwordEdit->text()).contains(QRegExp("[A-Z]"))) { - strength++; - } - - // increase strength by one, if password contains a non-word character - if ((passwordEdit->text()).contains(QRegExp("\\W"))) { - strength++; - } - - return strength; -} - QGroupBox *KeyGenDialog::create_key_usage_group_box() { auto *groupBox = new QGroupBox(this); @@ -395,7 +335,6 @@ void KeyGenDialog::set_signal_slot() { connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); connect(expireCheckBox, SIGNAL(stateChanged(int)), this, SLOT(slotExpireBoxChanged())); - connect(passwordEdit, SIGNAL(textChanged(QString)), this, SLOT(slotPasswordEditChanged())); connect(keyUsageCheckBoxes[0], SIGNAL(stateChanged(int)), this, SLOT(slotEncryptionBoxChanged(int))); connect(keyUsageCheckBoxes[1], SIGNAL(stateChanged(int)), this, SLOT(slotSigningBoxChanged(int))); @@ -407,12 +346,8 @@ void KeyGenDialog::set_signal_slot() { connect(noPassPhraseCheckBox, &QCheckBox::stateChanged, this, [this](int state) -> void { if(state == 0) { genKeyInfo.setNonPassPhrase(false); - passwordEdit->setDisabled(false); - repeatpwEdit->setDisabled(false); } else { genKeyInfo.setNonPassPhrase(true); - passwordEdit->setDisabled(true); - repeatpwEdit->setDisabled(true); } }); |