|
29 | 29 | #include "dialogs/FileDialog.h" |
30 | 30 | #include "dialogs/WarningDialog.h" |
31 | 31 |
|
32 | | -#include <QtCore/QDebug> |
33 | 32 | #include <QtCore/QDir> |
34 | 33 | #include <QtCore/QFileInfo> |
35 | 34 | #include <QtCore/QRegularExpression> |
36 | | -#include <QtCore/QtEndian> |
37 | 35 | #include <QtCore/QThread> |
38 | 36 | #include <QtCore/QUrl> |
39 | 37 | #include <QtCore/QUrlQuery> |
@@ -114,7 +112,7 @@ struct CryptoDoc::Private |
114 | 112 | writer_last_error = writer->getLastErrorStr(); |
115 | 113 | std::filesystem::remove(std::filesystem::path(fileName.toStdString())); |
116 | 114 | } |
117 | | - qDebug() << "Encryption result: " << result << " " << QString::fromStdString(writer->getLastErrorStr()); |
| 115 | + qCDebug(CRYPTO) << "Encryption result: " << result << " " << QString::fromStdString(writer->getLastErrorStr()); |
118 | 116 | delete writer; |
119 | 117 | ofs.close(); |
120 | 118 | if (result == libcdoc::OK) { |
@@ -332,9 +330,8 @@ bool CryptoDoc::canDecrypt(const QSslCertificate &cert) { |
332 | 330 | if (!d->reader) |
333 | 331 | return false; |
334 | 332 | QByteArray der = cert.toDer(); |
335 | | - libcdoc::Lock lock; |
336 | 333 | return d->reader->getLockForCert( |
337 | | - std::vector<uint8_t>(der.cbegin(), der.cend())) >= 0; |
| 334 | + std::vector<uint8_t>(der.cbegin(), der.cend())) >= 0; |
338 | 335 | } |
339 | 336 |
|
340 | 337 | void CryptoDoc::clear( const QString &file ) |
@@ -456,22 +453,21 @@ bool CryptoDoc::encrypt( const QString &filename, const QString& label, const QB |
456 | 453 | } |
457 | 454 | // I think the correct semantics is to fail if container is already encrypted |
458 | 455 | if(d->reader) return false; |
459 | | - if (secret.isEmpty()) { |
460 | | - // Encrypt for address list |
461 | | - if(d->keys.empty()) |
462 | | - { |
463 | | - WarningDialog::create() |
464 | | - ->withTitle(tr("Failed to encrypt document")) |
465 | | - ->withText(tr("No keys specified")) |
466 | | - ->open(); |
467 | | - return false; |
468 | | - } |
469 | | - } else { |
| 456 | + if (!secret.isEmpty()) { |
470 | 457 | // Encrypt with symmetric key |
471 | 458 | d->label = label; |
472 | 459 | d->crypto.secret.assign(secret.cbegin(), secret.cend()); |
473 | 460 | d->kdf_iter = kdf_iter; |
474 | 461 | } |
| 462 | + // Encrypt for address list |
| 463 | + else if(d->keys.empty()) |
| 464 | + { |
| 465 | + WarningDialog::create() |
| 466 | + ->withTitle(tr("Failed to encrypt document")) |
| 467 | + ->withText(tr("No keys specified")) |
| 468 | + ->open(); |
| 469 | + return false; |
| 470 | + } |
475 | 471 | libcdoc::result_t result = d->encrypt(); |
476 | 472 | d->label.clear(); |
477 | 473 | d->crypto.secret.clear(); |
|
0 commit comments