aboutsummaryrefslogtreecommitdiffstats
path: root/include/gpg/GpgGenKeyInfo.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/gpg/GpgGenKeyInfo.h120
1 files changed, 10 insertions, 110 deletions
diff --git a/include/gpg/GpgGenKeyInfo.h b/include/gpg/GpgGenKeyInfo.h
index f4273b05..ee2b0262 100644
--- a/include/gpg/GpgGenKeyInfo.h
+++ b/include/gpg/GpgGenKeyInfo.h
@@ -25,8 +25,7 @@
#ifndef GPG4USB_GPGGENKEYINFO_H
#define GPG4USB_GPGGENKEYINFO_H
-#include <QString>
-#include <QTime>
+#include "GpgFrontend.h"
class GenKeyInfo {
@@ -70,111 +69,35 @@ public:
return algo;
}
- void setAlgo(const QString &m_algo) {
-
- qDebug() << "set algo " << m_algo;
-
- reset_options();
-
- if (!this->subKey) {
- this->setAllowCertification(true);
- this->allowChangeCertification = false;
- }
-
- auto lower_algo = m_algo.toLower();
-
- if(lower_algo == "rsa") {
- /**
- * RSA is the world’s premier asymmetric cryptographic algorithm,
- * and is built on the difficulty of factoring extremely large composites.
- * GnuPG supports RSA with key sizes of between 1024 and 4096 bits.
- */
- suggestMinKeySize = 1024;
- suggestMaxKeySize = 4096;
- suggestSizeAdditionStep = 1024;
- setKeySize(2048);
-
- } else if (lower_algo == "dsa") {
- /**
- * Algorithm (DSA) as a government standard for digital signatures.
- * Originally, it supported key lengths between 512 and 1024 bits.
- * Recently, NIST has declared 512-bit keys obsolete:
- * now, DSA is available in 1024, 2048 and 3072-bit lengths.
- */
- setAllowEncryption(false);
- allowChangeEncryption = false;
-
- suggestMinKeySize = 1024;
- suggestMaxKeySize = 3072;
- suggestSizeAdditionStep = 1024;
- setKeySize(2048);
-
- } else if (lower_algo == "ed25519") {
- /**
- * GnuPG supports the Elgamal asymmetric encryption algorithm in key lengths ranging from 1024 to 4096 bits.
- */
-
- 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();
- }
+ void setAlgo(const QString &m_algo);
- }
+ [[nodiscard]] QString getKeySizeStr() const;
[[nodiscard]] int getKeySize() const {
return keySize;
}
- void setKeySize(int m_key_size) {
- if (m_key_size < suggestMinKeySize || m_key_size > suggestMaxKeySize) {
- return;
- }
- GenKeyInfo::keySize = m_key_size;
- }
+ void setKeySize(int m_key_size);
[[nodiscard]] const QDateTime &getExpired() const {
return expired;
}
- void setExpired(const QDateTime &m_expired) {
- auto current = QDateTime::currentDateTime();
- if (isNonExpired() && m_expired < current.addYears(2)) {
- GenKeyInfo::expired = m_expired;
- }
- }
+ void setExpired(const QDateTime &m_expired);
[[nodiscard]] bool isNonExpired() const {
return nonExpired;
}
- void setNonExpired(bool m_non_expired) {
- if (!m_non_expired) {
- this->expired = QDateTime(QDateTime::fromTime_t(0));
- }
- GenKeyInfo::nonExpired = m_non_expired;
- }
+ void setNonExpired(bool m_non_expired);
[[nodiscard]] bool isNoPassPhrase() const {
return this->noPassPhrase;
}
void setNonPassPhrase(bool m_non_pass_phrase) {
- GenKeyInfo::noPassPhrase = true;
+ GenKeyInfo::noPassPhrase = m_non_pass_phrase;
}
[[nodiscard]] bool isAllowSigning() const {
@@ -194,19 +117,13 @@ public:
return allowEncryption;
}
- void setAllowEncryption(bool m_allow_encryption) {
- if(allowChangeEncryption)
- GenKeyInfo::allowEncryption = m_allow_encryption;
- }
+ void setAllowEncryption(bool m_allow_encryption);
[[nodiscard]] bool isAllowCertification() const {
return allowCertification;
}
- void setAllowCertification(bool m_allow_certification) {
- if(allowChangeCertification)
- GenKeyInfo::allowCertification = m_allow_certification;
- }
+ void setAllowCertification(bool m_allow_certification);
[[nodiscard]] bool isAllowAuthentication() const {
return allowAuthentication;
@@ -266,24 +183,7 @@ private:
bool allowSigning = true;
bool allowChangeSigning = true;
- void reset_options() {
-
- allowChangeEncryption = true;
- setAllowEncryption(true);
-
- allowChangeCertification = true;
- setAllowCertification(true);
-
- allowChangeSigning = true;
- setAllowSigning(true);
-
- allowChangeAuthentication = true;
- setAllowAuthentication(true);
-
-
- passPhrase.clear();
-
- }
+ void reset_options();
public: