diff --git a/client/CDoc1.cpp b/client/CDoc1.cpp index 2fe10d397..d99e495db 100644 --- a/client/CDoc1.cpp +++ b/client/CDoc1.cpp @@ -133,7 +133,7 @@ CDoc1::CDoc1(const QString &path) //if(xml.name() == QLatin1String("KeyName")) // key->name = xml.readElementText(); // EncryptedData/KeyInfo/EncryptedKey/EncryptionMethod - else if(xml.name() == QLatin1String("EncryptionMethod")) + if(xml.name() == QLatin1String("EncryptionMethod")) key->method = xml.attributes().value(QLatin1String("Algorithm")).toString(); // EncryptedData/KeyInfo/EncryptedKey/KeyInfo/AgreementMethod else if(xml.name() == QLatin1String("AgreementMethod")) { @@ -310,16 +310,16 @@ std::shared_ptr CDoc1::getDecryptionKey(const QSslCertificate &cert) const std::shared_ptr k = std::static_pointer_cast(key); if(!ENC_MTH.contains(method) || k->cert != cert || - k->encrypted_fmk.isEmpty()) + k->encrypted_fmk.isEmpty()) continue; if(cert.publicKey().algorithm() == QSsl::Rsa && k->method == RSA_MTH) return k; if(cert.publicKey().algorithm() == QSsl::Ec && !k->publicKey.isEmpty() && - KWAES_SIZE.contains(k->method) /* && + KWAES_SIZE.contains(k->method) /* && k->derive == CONCATKDF_MTH && - k->agreement == AGREEMENT_MTH*/ ) + k->agreement == AGREEMENT_MTH*/ ) return k; } return {}; @@ -514,7 +514,7 @@ bool CDoc1::save(const QString &path) default: concatDigest = SHA512_MTH; break; } QByteArray encryptionKey = Crypto::concatKDF(SHA_MTH[concatDigest], KWAES_SIZE[encryptionMethod], - sharedSecret, props.value(QStringLiteral("DocumentFormat")).toUtf8() + SsDer + ckey->cert.toDer()); + sharedSecret, props.value(QStringLiteral("DocumentFormat")).toUtf8() + SsDer + ckey->cert.toDer()); #ifndef NDEBUG qDebug() << "ENC Ss" << SsDer.toHex(); qDebug() << "ENC Ksr" << sharedSecret.toHex(); @@ -539,7 +539,7 @@ bool CDoc1::save(const QString &path) writeElement(w, XENC11, QStringLiteral("ConcatKDFParams"), { {QStringLiteral("AlgorithmID"), QStringLiteral("00") + props.value(QStringLiteral("DocumentFormat")).toUtf8().toHex()}, {QStringLiteral("PartyUInfo"), QStringLiteral("00") + SsDer.toHex()}, - {QStringLiteral("PartyVInfo"), QStringLiteral("00") + ckey->cert.toDer().toHex()}, + {QStringLiteral("PartyVInfo"), QStringLiteral("00") + ckey->cert.toDer().toHex()}, }, [&]{ writeElement(w, DS, QStringLiteral("DigestMethod"), { {QStringLiteral("Algorithm"), concatDigest}, @@ -589,32 +589,32 @@ bool CDoc1::save(const QString &path) return true; } -QByteArray CDoc1::getFMK(const CKey &key, const QByteArray& secret) +QByteArray CDoc1::getFMK(const CKey &key, const QByteArray& /*secret*/) { if (key.type != CKey::Type::CDOC1) { setLastError(QStringLiteral("Not a CDoc1 key")); return {}; } - const CKeyCDoc1& ckey = static_cast(key); + const auto& ckey = static_cast(key); setLastError({}); QByteArray decryptedKey = qApp->signer()->decrypt([&ckey](QCryptoBackend *backend) { if(ckey.pk_type == CKey::PKType::RSA) - return backend->decrypt(ckey.encrypted_fmk, false); + return backend->decrypt(ckey.encrypted_fmk, false); return backend->deriveConcatKDF(ckey.publicKey, SHA_MTH[ckey.concatDigest], int(KWAES_SIZE[ckey.method]), ckey.AlgorithmID, ckey.PartyUInfo, ckey.PartyVInfo); -}); -if(decryptedKey.isEmpty()) -{ - setLastError(QStringLiteral("Failed to decrypt/derive key")); - return {}; -} -if(ckey.pk_type == CKey::PKType::RSA) -return decryptedKey; + }); + if(decryptedKey.isEmpty()) + { + setLastError(QStringLiteral("Failed to decrypt/derive key")); + return {}; + } + if(ckey.pk_type == CKey::PKType::RSA) + return decryptedKey; #ifndef NDEBUG - qDebug() << "DEC Ss" << ckey.publicKey.toHex(); + qDebug() << "DEC Ss" << ckey.publicKey.toHex(); qDebug() << "DEC ConcatKDF" << decryptedKey.toHex(); #endif -return Crypto::aes_unwrap(decryptedKey, ckey.encrypted_fmk); + return Crypto::aes_unwrap(decryptedKey, ckey.encrypted_fmk); } int CDoc1::version() diff --git a/client/CDoc2.cpp b/client/CDoc2.cpp index 6b88899d6..7b7d310c6 100644 --- a/client/CDoc2.cpp +++ b/client/CDoc2.cpp @@ -408,8 +408,8 @@ CDoc2::isCDoc2File(const QString& path) return true; } -CDoc2::CDoc2(const QString &_path) - : path(_path) +CDoc2::CDoc2(QString _path) + : path(std::move(_path)) /* : QFile(path) */ { using namespace cdoc20::recipients; @@ -558,7 +558,7 @@ CDoc2::CDoc2(const QString &_path) std::unique_ptr CDoc2::load(const QString& path) { - CDoc2 *cdoc = new CDoc2(path); + auto *cdoc = new CDoc2(path); return std::unique_ptr(cdoc); } @@ -566,7 +566,7 @@ CKey::DecryptionStatus CDoc2::canDecrypt(const QSslCertificate &cert) const { CKey::DecryptionStatus status = CKey::DecryptionStatus::CANNOT_DECRYPT; - for (std::shared_ptr key: keys) { + for (const std::shared_ptr &key: keys) { if (key->isTheSameRecipient(cert)) return CKey::CAN_DECRYPT; if (key->isSymmetric()) status = CKey::DecryptionStatus::NEED_KEY; } @@ -638,19 +638,19 @@ bool CDoc2::save(const QString &_path) return builder.CreateString(utf8.data(), size_t(utf8.length())); }; - auto sendToServer = [this] (const QString& keyserver_id, const QByteArray &recipient_id, const QByteArray &key_material, QLatin1String type) -> QString { - if(keyserver_id.isEmpty()) { - setLastError(QStringLiteral("keyserver_id cannot be empty")); - return {}; - } - QNetworkRequest req = cdoc20::req(keyserver_id); - if(req.url().isEmpty()) { - setLastError(QStringLiteral("No valid config found for keyserver_id: %1").arg(keyserver_id)); - return {}; - } - if(!cdoc20::checkConnection()) { - return {}; - } + auto sendToServer = [this] (const QString& keyserver_id, const QByteArray &recipient_id, const QByteArray &key_material, QLatin1String type) -> QString { + if(keyserver_id.isEmpty()) { + setLastError(QStringLiteral("keyserver_id cannot be empty")); + return {}; + } + QNetworkRequest req = cdoc20::req(keyserver_id); + if(req.url().isEmpty()) { + setLastError(QStringLiteral("No valid config found for keyserver_id: %1").arg(keyserver_id)); + return {}; + } + if(!cdoc20::checkConnection()) { + return {}; + } QScopedPointer nam(CheckConnection::setupNAM(req, Settings::CDOC2_POST_CERT)); QEventLoop e; QNetworkReply *reply = nam->post(req, QJsonDocument({ @@ -662,22 +662,22 @@ bool CDoc2::save(const QString &_path) e.exec(); QString transaction_id; if(reply->error() == QNetworkReply::NoError && - reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 201) { - transaction_id = QString::fromLatin1(reply->rawHeader("Location")).remove(QLatin1String("/key-capsules/")); - } else { - setLastError(reply->errorString()); - return {}; - } - if(transaction_id.isEmpty()) - setLastError(QStringLiteral("Failed to post key capsule")); - return transaction_id; + reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 201) { + transaction_id = QString::fromLatin1(reply->rawHeader("Location")).remove(QLatin1String("/key-capsules/")); + } else { + setLastError(reply->errorString()); + return {}; + } + if(transaction_id.isEmpty()) + setLastError(QStringLiteral("Failed to post key capsule")); + return transaction_id; }; - for(std::shared_ptr key: keys) { + for(const std::shared_ptr &key: keys) { if (!key->isPKI()) { return setLastError(QStringLiteral("Invalid key type")); } - const CKeyPKI& pki = static_cast(*key); + const auto& pki = static_cast(*key); if(pki.pk_type == CKey::PKType::RSA) { QByteArray kek = Crypto::random(fmk.size()); QByteArray xor_key = Crypto::xor_data(fmk, kek); @@ -691,36 +691,36 @@ bool CDoc2::save(const QString &_path) qDebug() << "xor" << xor_key.toHex(); qDebug() << "encrytpedKek" << encrytpedKek.toHex(); #endif - if(!Settings::CDOC2_USE_KEYSERVER) { - auto rsaPublicKey = cdoc20::recipients::CreateRSAPublicKeyCapsule(builder, - toVector(pki.rcpt_key), toVector(encrytpedKek)); - auto offs = cdoc20::header::CreateRecipientRecord(builder, - cdoc20::recipients::Capsule::RSAPublicKeyCapsule, rsaPublicKey.Union(), - toString(pki.label), toVector(xor_key), cdoc20::header::FMKEncryptionMethod::XOR); - recipients.push_back(offs); - } else { - QString keyserver_id = Settings::CDOC2_DEFAULT_KEYSERVER; - QString transaction_id = sendToServer(keyserver_id, pki.rcpt_key, encrytpedKek, QLatin1String("rsa")); - if (transaction_id.isEmpty()) return false; - auto rsaKeyServer = cdoc20::recipients::CreateRsaKeyDetails(builder, toVector(pki.rcpt_key)); - auto keyServer = cdoc20::recipients::CreateKeyServerCapsule(builder, - cdoc20::recipients::KeyDetailsUnion::RsaKeyDetails, - rsaKeyServer.Union(), toString(keyserver_id), toString(transaction_id)); - auto offs = cdoc20::header::CreateRecipientRecord(builder, - cdoc20::recipients::Capsule::KeyServerCapsule, keyServer.Union(), - toString(pki.label), toVector(xor_key), cdoc20::header::FMKEncryptionMethod::XOR); - recipients.push_back(offs); - } - } else { - auto publicKey = Crypto::fromECPublicKeyDer(pki.rcpt_key, NID_secp384r1); - if(!publicKey) return false; - auto ephKey = Crypto::genECKey(publicKey.get()); - QByteArray sharedSecret = Crypto::derive(ephKey.get(), publicKey.get()); - QByteArray ephPublicKeyDer = Crypto::toPublicKeyDer(ephKey.get()); - QByteArray kekPm = Crypto::extract(sharedSecret, KEKPREMASTER); - QByteArray info = KEK + cdoc20::header::EnumNameFMKEncryptionMethod(cdoc20::header::FMKEncryptionMethod::XOR) + pki.rcpt_key + ephPublicKeyDer; - QByteArray kek = Crypto::expand(kekPm, info, fmk.size()); - QByteArray xor_key = Crypto::xor_data(fmk, kek); + if(!Settings::CDOC2_USE_KEYSERVER) { + auto rsaPublicKey = cdoc20::recipients::CreateRSAPublicKeyCapsule(builder, + toVector(pki.rcpt_key), toVector(encrytpedKek)); + auto offs = cdoc20::header::CreateRecipientRecord(builder, + cdoc20::recipients::Capsule::RSAPublicKeyCapsule, rsaPublicKey.Union(), + toString(pki.label), toVector(xor_key), cdoc20::header::FMKEncryptionMethod::XOR); + recipients.push_back(offs); + } else { + QString keyserver_id = Settings::CDOC2_DEFAULT_KEYSERVER; + QString transaction_id = sendToServer(keyserver_id, pki.rcpt_key, encrytpedKek, QLatin1String("rsa")); + if (transaction_id.isEmpty()) return false; + auto rsaKeyServer = cdoc20::recipients::CreateRsaKeyDetails(builder, toVector(pki.rcpt_key)); + auto keyServer = cdoc20::recipients::CreateKeyServerCapsule(builder, + cdoc20::recipients::KeyDetailsUnion::RsaKeyDetails, + rsaKeyServer.Union(), toString(keyserver_id), toString(transaction_id)); + auto offs = cdoc20::header::CreateRecipientRecord(builder, + cdoc20::recipients::Capsule::KeyServerCapsule, keyServer.Union(), + toString(pki.label), toVector(xor_key), cdoc20::header::FMKEncryptionMethod::XOR); + recipients.push_back(offs); + } + } else { + auto publicKey = Crypto::fromECPublicKeyDer(pki.rcpt_key, NID_secp384r1); + if(!publicKey) return false; + auto ephKey = Crypto::genECKey(publicKey.get()); + QByteArray sharedSecret = Crypto::derive(ephKey.get(), publicKey.get()); + QByteArray ephPublicKeyDer = Crypto::toPublicKeyDer(ephKey.get()); + QByteArray kekPm = Crypto::extract(sharedSecret, KEKPREMASTER); + QByteArray info = KEK + cdoc20::header::EnumNameFMKEncryptionMethod(cdoc20::header::FMKEncryptionMethod::XOR) + pki.rcpt_key + ephPublicKeyDer; + QByteArray kek = Crypto::expand(kekPm, info, fmk.size()); + QByteArray xor_key = Crypto::xor_data(fmk, kek); #ifndef NDEBUG qDebug() << "publicKeyDer" << pki.rcpt_key.toHex(); qDebug() << "ephPublicKeyDer" << ephPublicKeyDer.toHex(); @@ -798,7 +798,7 @@ bool CDoc2::save(const QString &_path) } bool -CDoc2::save(QString _path, const std::vector& files, const QString& label, const QByteArray& secret, unsigned int kdf_iter) +CDoc2::save(const QString& _path, const std::vector& files, const QString& label, const QByteArray& secret, unsigned int kdf_iter) { QByteArray fmk = Crypto::extract(Crypto::random(KEY_LEN), SALT); QByteArray cek = Crypto::expand(fmk, CEK); @@ -939,7 +939,7 @@ QByteArray CDoc2::getFMK(const CKey &key, const QByteArray& secret) QByteArray kek; if (key.isSymmetric()) { // Symmetric key - const CKeySymmetric &sk = static_cast(key); + const auto &sk = static_cast(key); if (sk.kdf_iter > 0) { #ifndef NDEBUG qDebug() << "Password based symmetric key: " << key.label; @@ -963,13 +963,13 @@ QByteArray CDoc2::getFMK(const CKey &key, const QByteArray& secret) } } else { // Public/private key - const CKeyPKI &pki = static_cast(key); + const auto &pki = static_cast(key); QByteArray key_material; if(key.type == CKey::Type::SERVER) { - const CKeyServer &sk = static_cast(key); + const auto &sk = static_cast(key); key_material = fetchKeyMaterial(sk); } else if (key.type == CKey::PUBLIC_KEY) { - const CKeyPublicKey& pk = static_cast(key); + const auto& pk = static_cast(key); key_material = pk.key_material; } #ifndef NDEBUG @@ -984,7 +984,7 @@ QByteArray CDoc2::getFMK(const CKey &key, const QByteArray& secret) kek = qApp->signer()->decrypt([&pki, &key_material](QCryptoBackend *backend) { QByteArray kekPm = backend->deriveHMACExtract(key_material, KEKPREMASTER, KEY_LEN); #ifndef NDEBUG - qDebug() << "kekPm" << kekPm.toHex(); + qDebug() << "kekPm" << kekPm.toHex(); #endif QByteArray info = KEK + cdoc20::header::EnumNameFMKEncryptionMethod(cdoc20::header::FMKEncryptionMethod::XOR) + pki.rcpt_key + key_material; return Crypto::expand(kekPm, info, KEY_LEN); @@ -1008,11 +1008,11 @@ QByteArray CDoc2::getFMK(const CKey &key, const QByteArray& secret) qDebug() << "hhk" << hhk.toHex(); qDebug() << "hmac" << headerHMAC.toHex(); #endif - if(Crypto::sign_hmac(hhk, header_data) != headerHMAC) { - setLastError(QStringLiteral("CDoc 2.0 hash mismatch")); - return {}; - } - return fmk; + if(Crypto::sign_hmac(hhk, header_data) != headerHMAC) { + setLastError(QStringLiteral("CDoc 2.0 hash mismatch")); + return {}; + } + return fmk; } int CDoc2::version() diff --git a/client/CDoc2.h b/client/CDoc2.h index aae9cb9b0..5213c200d 100644 --- a/client/CDoc2.h +++ b/client/CDoc2.h @@ -36,7 +36,7 @@ class CDoc2 final: public CDoc, private QObject /*, private QFile */ { bool save(const QString &path) final; // Write payload encrypted with sinbgle symmetric key - static bool save(QString path, const std::vector& files, const QString& label, const QByteArray& secret, unsigned int kdf_iter); + static bool save(const QString& path, const std::vector& files, const QString& label, const QByteArray& secret, unsigned int kdf_iter); QByteArray getFMK(const CKey &key, const QByteArray& secret) final; int version() final; @@ -44,7 +44,7 @@ class CDoc2 final: public CDoc, private QObject /*, private QFile */ { static std::unique_ptr load(const QString& _path); private: - CDoc2(const QString &path); + CDoc2(QString path); QString path; QByteArray header_data, headerHMAC; diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 1ad15cc8c..44377dffd 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -89,7 +89,6 @@ add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE TokenData.cpp TokenData.h Utils.h - dialogs/PasswordDialog.h dialogs/PasswordDialog.cpp dialogs/PasswordDialog.ui ) target_link_libraries(${PROJECT_NAME} diff --git a/client/CryptoDoc.cpp b/client/CryptoDoc.cpp index 36dbcf887..fcba866f0 100644 --- a/client/CryptoDoc.cpp +++ b/client/CryptoDoc.cpp @@ -125,7 +125,7 @@ bool CDocumentModel::addFile(const QString &file, const QString &mime) [&fileName](const auto &containerFile) { return containerFile.name == fileName; })) { WarningDialog::show(DocumentModel::tr("Cannot add the file to the envelope. File '%1' is already in container.") - .arg(FileDialog::normalized(fileName))); + .arg(FileDialog::normalized(fileName))); return false; } @@ -231,11 +231,11 @@ CKey::isTheSameRecipient(const CKey& other) const { QByteArray this_key, other_key; if (this->isCertificate()) { - const CKeyCert& ckc = static_cast(*this); + const auto& ckc = static_cast(*this); this_key = ckc.cert.publicKey().toDer(); } if (other.isCertificate()) { - const CKeyCert& ckc = static_cast(other); + const auto& ckc = static_cast(other); other_key = ckc.cert.publicKey().toDer(); } if (this_key.isEmpty() || other_key.isEmpty()) return false; @@ -246,7 +246,7 @@ bool CKey::isTheSameRecipient(const QSslCertificate &cert) const { if (!isPKI()) return false; - const CKeyPKI& pki = static_cast(*this); + const auto& pki = static_cast(*this); QByteArray this_key = pki.rcpt_key; QSslKey k = cert.publicKey(); QByteArray other_key = Crypto::toPublicKeyDer(k); @@ -288,7 +288,7 @@ void CKeyCert::setCert(const QSslCertificate &c) } std::shared_ptr -CKeyServer::fromKey(QByteArray _key, PKType _pk_type) { +CKeyServer::fromKey(const QByteArray &_key, PKType _pk_type) { return std::shared_ptr(new CKeyServer(_key, _pk_type)); } @@ -308,11 +308,11 @@ CryptoDoc::supportsSymmetricKeys() const return d->cdoc->version() >= 2; } -bool CryptoDoc::addKey(std::shared_ptr key ) +bool CryptoDoc::addKey(const std::shared_ptr &key) { if(d->isEncryptedWarning()) return false; - for (std::shared_ptr k: d->cdoc->keys) { + for (const std::shared_ptr &k: d->cdoc->keys) { if (k->isTheSameRecipient(*key)) { WarningDialog::show(tr("Key already exists")); return false; diff --git a/client/CryptoDoc.h b/client/CryptoDoc.h index c92ab2188..9a8344050 100644 --- a/client/CryptoDoc.h +++ b/client/CryptoDoc.h @@ -69,7 +69,7 @@ struct CKey bool isTheSameRecipient(const QSslCertificate &cert) const; protected: - CKey(Type _type) : type(_type) {}; + CKey(Type _type) : type(_type) {} private: bool operator==(const CKey &other) const { return false; } }; @@ -83,9 +83,9 @@ struct CKeySymmetric : public CKey { // PBKDF QByteArray pw_salt; // 0 symmetric key, >0 password - int32_t kdf_iter; + int32_t kdf_iter{}; - CKeySymmetric(const QByteArray& _salt) : CKey(Type::SYMMETRIC_KEY), salt(_salt), kdf_iter(0) {} + CKeySymmetric(QByteArray _salt) : CKey(Type::SYMMETRIC_KEY), salt(std::move(_salt)) {} }; // Base PKI key @@ -98,8 +98,8 @@ struct CKeyPKI : public CKey { QByteArray rcpt_key; protected: - CKeyPKI(Type _type) : CKey(_type), pk_type(PKType::ECC) {}; - CKeyPKI(Type _type, PKType _pk_type, QByteArray _rcpt_key) : CKey(_type), pk_type(_pk_type), rcpt_key(_rcpt_key) {}; + CKeyPKI(Type _type) : CKey(_type), pk_type(PKType::ECC) {} + CKeyPKI(Type _type, PKType _pk_type, QByteArray _rcpt_key) : CKey(_type), pk_type(_pk_type), rcpt_key(std::move(_rcpt_key)) {} }; @@ -110,12 +110,12 @@ struct CKeyPKI : public CKey { struct CKeyCert : public CKeyPKI { QSslCertificate cert; - CKeyCert(const QSslCertificate &cert) : CKeyCert(CKey::Type::CERTIFICATE, cert) {}; + CKeyCert(const QSslCertificate &cert) : CKeyCert(CKey::Type::CERTIFICATE, cert) {} void setCert(const QSslCertificate &c); protected: - CKeyCert(Type _type) : CKeyPKI(_type) {}; + CKeyCert(Type _type) : CKeyPKI(_type) {} CKeyCert(Type _type, const QSslCertificate &cert); }; @@ -129,7 +129,7 @@ struct CKeyCDoc1 : public CKeyCert { QString concatDigest, method; QByteArray AlgorithmID, PartyUInfo, PartyVInfo; - CKeyCDoc1() : CKeyCert(Type::CDOC1) {}; + CKeyCDoc1() : CKeyCert(Type::CDOC1) {} }; // CDoc2 PKI key with key material @@ -140,7 +140,7 @@ struct CKeyPublicKey : public CKeyPKI { // Either ECC public key or RSA encrypted kek QByteArray key_material; - CKeyPublicKey(PKType _pk_type, QByteArray _rcpt_key) : CKeyPKI(Type::PUBLIC_KEY, _pk_type, _rcpt_key) {}; + CKeyPublicKey(PKType _pk_type, QByteArray _rcpt_key) : CKeyPKI(Type::PUBLIC_KEY, _pk_type, std::move(_rcpt_key)) {} }; // CDoc2 PKI key with server info @@ -151,9 +151,9 @@ struct CKeyServer : public CKeyPKI { // Server info QString keyserver_id, transaction_id; - static std::shared_ptr fromKey(QByteArray _key, PKType _pk_type); + static std::shared_ptr fromKey(const QByteArray &_key, PKType _pk_type); protected: - CKeyServer(QByteArray _rcpt_key, PKType _pk_type) : CKeyPKI(Type::SERVER, _pk_type, _rcpt_key) {}; + CKeyServer(QByteArray _rcpt_key, PKType _pk_type) : CKeyPKI(Type::SERVER, _pk_type, std::move(_rcpt_key)) {} }; class CDoc @@ -189,7 +189,7 @@ class CryptoDoc final: public QObject ~CryptoDoc() final; bool supportsSymmetricKeys() const; - bool addKey(std::shared_ptr key ); + bool addKey(const std::shared_ptr &key); bool canDecrypt(const QSslCertificate &cert); void clear(const QString &file = {}); bool decrypt(std::shared_ptr key, const QByteArray& secret); diff --git a/client/MainWindow.cpp b/client/MainWindow.cpp index 8eaa03668..11fcb192f 100644 --- a/client/MainWindow.cpp +++ b/client/MainWindow.cpp @@ -260,8 +260,7 @@ void MainWindow::decrypt(std::shared_ptr key) if (cryptoDoc->decrypt(key, secret)) { ui->cryptoContainerPage->transition(cryptoDoc, qApp->signer()->tokenauth().cert()); - auto *notification = new FadeInNotification(this, WHITE, MANTIS, 110); - notification->start( tr("Decryption succeeded!"), 750, 3000, 1200 ); + FadeInNotification::success(ui->topBar, tr("Decryption succeeded!")); } } @@ -1018,7 +1017,7 @@ bool MainWindow::validateFiles(const QString &container, const QStringList &file [containerInfo] (const QString &file) { return containerInfo == QFileInfo(file); })) return true; auto *dlg = new WarningDialog(tr("Cannot add container to same container\n%1") - .arg(FileDialog::normalized(container)), this); + .arg(FileDialog::normalized(container)), this); dlg->setCancelText(WarningDialog::Cancel); dlg->open(); return false; diff --git a/client/widgets/AddressItem.cpp b/client/widgets/AddressItem.cpp index bef232e9a..cb4fa92ad 100644 --- a/client/widgets/AddressItem.cpp +++ b/client/widgets/AddressItem.cpp @@ -39,7 +39,7 @@ class AddressItem::Private: public Ui::AddressItem bool yourself = false; }; -AddressItem::AddressItem(std::shared_ptr key, QWidget *parent, bool showIcon) +AddressItem::AddressItem(const std::shared_ptr& key, QWidget *parent, bool showIcon) : Item(parent) , ui(new Private) { @@ -80,7 +80,7 @@ AddressItem::AddressItem(std::shared_ptr key, QWidget *parent, bool showIc ui->label = key->label.toHtmlEscaped(); } if(ui->label.isEmpty() && ui->key->type == CKey::PUBLIC_KEY) { - const CKeyPublicKey& pk = static_cast(*ui->key); + const auto& pk = static_cast(*ui->key); ui->label = pk.key_material; } setIdType(); @@ -113,12 +113,12 @@ bool AddressItem::eventFilter(QObject *o, QEvent *e) return Item::eventFilter(o, e); } -const std::shared_ptr AddressItem::getKey() const +std::shared_ptr AddressItem::getKey() const { return ui->key; } -void AddressItem::idChanged(std::shared_ptr key) +void AddressItem::idChanged(const std::shared_ptr& key) { ui->yourself = key->isTheSameRecipient(*ui->key); setName(); @@ -197,24 +197,23 @@ void AddressItem::setIdType() str += QStringLiteral(" - "); DateTime date(cert.expiryDate().toLocalTime()); ui->idType->setText(QStringLiteral("%1%2 %3").arg(str, - cert.isValid() ? tr("Expires on") : tr("Expired on"), - date.formatDate(QStringLiteral("dd. MMMM yyyy")))); + cert.isValid() ? tr("Expires on") : tr("Expired on"), + date.formatDate(QStringLiteral("dd. MMMM yyyy")))); } else { - QString type = (pki->pk_type == CKey::PKType::RSA) ? "RSA" : "ECC"; + QString type = (pki->pk_type == CKey::PKType::RSA) ? QStringLiteral("RSA") : QStringLiteral("ECC"); ui->idType->setHidden(false); - ui->idType->setText(type + " public key"); + ui->idType->setText(type + tr(" public key")); } } else if (ui->key->isSymmetric()) { std::shared_ptr ckd = std::static_pointer_cast(ui->key); ui->idType->setHidden(false); if (ckd->kdf_iter > 0) { - ui->idType->setText("Password derived key"); + ui->idType->setText(tr("Password derived key")); } else { - ui->idType->setText("Symmetric key"); + ui->idType->setText(tr("Symmetric key")); } } else { ui->idType->setHidden(false); - ui->idType->setText("Unknown key type"); + ui->idType->setText(tr("Unknown key type")); } } - diff --git a/client/widgets/AddressItem.h b/client/widgets/AddressItem.h index 5fb3a8ccb..a88ed5319 100644 --- a/client/widgets/AddressItem.h +++ b/client/widgets/AddressItem.h @@ -38,11 +38,11 @@ class AddressItem final : public Item Added, }; - explicit AddressItem(std::shared_ptr k, QWidget *parent = {}, bool showIcon = false); + explicit AddressItem(const std::shared_ptr& k, QWidget *parent = {}, bool showIcon = false); ~AddressItem() final; - const std::shared_ptr getKey() const; - void idChanged(std::shared_ptr cert); + std::shared_ptr getKey() const; + void idChanged(const std::shared_ptr& cert); void idChanged(const SslCertificate &cert) final; void initTabOrder(QWidget *item) final; QWidget* lastTabWidget() final; diff --git a/client/widgets/AddressItem.ui b/client/widgets/AddressItem.ui index be7d9adfd..de3704ed5 100644 --- a/client/widgets/AddressItem.ui +++ b/client/widgets/AddressItem.ui @@ -81,31 +81,6 @@ background-color: #00AEE5; 0 - - - - false - - - - 0 - 25 - - - - - 16777215 - 25 - - - - Added - - - ADDED - - - @@ -125,28 +100,55 @@ background-color: #00AEE5; - - - - - 0 - 25 - + + + + + Roboto + 14 + false + false + - - - 16777215 - 25 - + + Qt::TabFocus - - PointingHandCursor + + border: none; - - Add + + MARI MAASIKAS MUSTIKAS 48405050123 (Sina ise) + + + true + + + + + + + + Roboto + 11 + false + false + + + + Qt::TabFocus + + + color: #727679;border: none; - ADD + ID-card + + + + + + + DECRYPT @@ -186,72 +188,70 @@ background-color: #00AEE5; - - - - - Roboto - 11 - false - false - + + + + false - - Qt::TabFocus + + + 0 + 25 + - - color: #727679;border: none; + + + 16777215 + 25 + + + + Added - ID-card + ADDED - - - - - Roboto - 14 - false - false - - - - Qt::TabFocus + + + + + 0 + 25 + - - border: none; + + + 16777215 + 25 + - - MARI MAASIKAS MUSTIKAS 48405050123 (Sina ise) + + PointingHandCursor - - true + + Add - - - - - DECRYPT + ADD - - QSvgWidget - QWidget -
QSvgWidget
- 1 -
LabelButton QToolButton
widgets/LabelButton.h
+ + QSvgWidget + QWidget +
QtSvg/QSvgWidget
+ 1 +
diff --git a/client/widgets/ContainerPage.cpp b/client/widgets/ContainerPage.cpp index 7b078301a..bdd783979 100644 --- a/client/widgets/ContainerPage.cpp +++ b/client/widgets/ContainerPage.cpp @@ -417,7 +417,7 @@ void ContainerPage::updatePanes(ria::qdigidoc4::ContainerState state, CryptoDoc for(QWidget *button: buttons) button->setVisible(visible); }; - switch(state) + switch( state ) { case UnsignedContainer: cancelText = QT_TR_NOOP("CANCEL"); @@ -498,4 +498,3 @@ void ContainerPage::translateLabels() ui->convert->setText(tr(convertText)); ui->convert->setAccessibleName(tr(convertText).toLower()); } - diff --git a/client/widgets/ContainerPage.ui b/client/widgets/ContainerPage.ui index 05cfd1531..a1832cc11 100644 --- a/client/widgets/ContainerPage.ui +++ b/client/widgets/ContainerPage.ui @@ -214,8 +214,6 @@ background-color: #F4F5F6; Roboto Condensed 12 - false - false
@@ -305,8 +303,6 @@ border: none; Roboto Condensed 12 - false - false @@ -344,8 +340,6 @@ border: none; Roboto Condensed 12 - false - false @@ -382,8 +376,6 @@ border: none; 12 - false - false @@ -422,8 +414,6 @@ border: none; Roboto Condensed 12 - false - false @@ -466,17 +456,17 @@ border: none;
+ + LabelButton + QToolButton +
widgets/LabelButton.h
+
ItemList QScrollArea
widgets/ItemList.h
1
- - LabelButton - QToolButton -
widgets/LabelButton.h
-
FileList QScrollArea diff --git a/common b/common index 27319130f..fbe6fab8b 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 27319130f517cc085531d59beda5779b5b223b4e +Subproject commit fbe6fab8bddab463e101b857c31c69ee9595c16b