From feb745457be289b60039095ba5e402ae18314a48 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Sun, 24 May 2020 09:11:12 +0200 Subject: [PATCH] new gui elements for encryption --- silentdragon-lite.pro | 1 + src/encryption.ui | 10 +-- src/mainwindow.cpp | 39 +++++---- src/removeencryption.ui | 171 ++++++++++++++++++++++++++++++++++------ 4 files changed, 173 insertions(+), 48 deletions(-) diff --git a/silentdragon-lite.pro b/silentdragon-lite.pro index 4fe9ad0..89c9012 100644 --- a/silentdragon-lite.pro +++ b/silentdragon-lite.pro @@ -143,6 +143,7 @@ FORMS += \ src/requestContactDialog.ui \ src/newrecurring.ui \ src/requestdialog.ui \ + src/removeencryption.ui \ src/recurringmultiple.ui \ src/chatbubbleme.ui \ src/chatbubblepartner.ui diff --git a/src/encryption.ui b/src/encryption.ui index e0b3e2f..ae2643b 100644 --- a/src/encryption.ui +++ b/src/encryption.ui @@ -30,7 +30,7 @@ - <html><head/><body><p><span style=" font-size:14pt; color:#ef2929;">WARNING:</span> If you forget your password, the only way to recover the wallet is from the seed phrase. If you dont have Backup your seed phrase, please do it now!</p></body></html> + <html><head/><body><p><span style=" font-size:14pt; color:#ef2929;">WARNING:</span> If you forget your passphrase the only way to recover the wallet is from the seed phrase. If you dont have Backup your seed phrase, please do it now!</p></body></html> Qt::AlignCenter @@ -63,7 +63,7 @@ - <html><head/><body><p>10 letters minimum</p></body></html> + <html><head/><body><p>16 letters minimum</p></body></html> @@ -73,7 +73,7 @@ color: red; - Passwords don't match + Passphrase don't match Qt::AlignCenter @@ -83,7 +83,7 @@ - Encryption Password: + Encryption Passphrase: @@ -97,7 +97,7 @@ - Confirm Password: + Confirm Passphrase: diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e7d175b..fd5be39 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -21,7 +21,8 @@ #include "ui_requestContactDialog.h" #include "chatmodel.h" #include "requestdialog.h" -#include "ui_startupencryption.h" +#include "ui_startupencryption.h" +#include "ui_removeencryption.h" #include "websockets.h" #include "sodium.h" #include "sodium/crypto_generichash_blake2b.h" @@ -268,18 +269,16 @@ void MainWindow::closeEvent(QCloseEvent* event) { if(fileExists(QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)).filePath(".silentdragonlite/silentdragonlite-wallet-enc.dat"))) { - - // delete old file before auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); - QFile file1(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet-enc.dat")); - file1.remove(); + QFile fileoldencryption(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet-enc.dat")); + fileoldencryption.remove(); - // Encrypt our wallet.dat - QString str = "123";///just for testing. We set the user pw here - // QString str = ed.txtPassword->text(); // data comes from user inputs - int length = str.length(); + // Encrypt our wallet.dat + QString str = "123";///just for testing. We set the user pw here + // QString str = ed.txtPassword->text(); // data comes from user inputs + int length = str.length(); char *sequence = NULL; sequence = new char[length+1]; @@ -309,7 +308,7 @@ void MainWindow::closeEvent(QCloseEvent* event) { } auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); - // auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); + // auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); QString source_file = dir.filePath("addresslabels.dat"); QString target_enc_file = dir.filePath("addresslabels.dat.enc"); QString sourceWallet_file = dirHome.filePath(".silentdragonlite/silentdragonlite-wallet.dat"); @@ -318,14 +317,16 @@ void MainWindow::closeEvent(QCloseEvent* event) { FileEncryption::encrypt(target_enc_file, source_file, key); FileEncryption::encrypt(target_encWallet_file, sourceWallet_file, key); - } -///////////////// we rename the plaintext wallet.dat to Backup, for testing. - auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); - QFile file1(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet.datBACKUP")); - file1.remove(); + ///////////////// we rename the plaintext wallet.dat to Backup, for testing. + + QFile fileoldbackup(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet.datBACKUP")); + fileoldbackup.remove(); QFile file(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet.dat")); file.rename(dirHome.filePath(".silentdragonlite/silentdragonlite-wallet.datBACKUP")); + } + + // Bubble up if (event) QMainWindow::closeEvent(event); @@ -351,11 +352,11 @@ void MainWindow::encryptWallet() { // Enable the OK button if the passwords match. QString password = ed.txtPassword->text(); if (!ed.txtPassword->text().isEmpty() && - ed.txtPassword->text() == ed.txtConfirmPassword->text() && password.size() >= 10) { + ed.txtPassword->text() == ed.txtConfirmPassword->text() && password.size() >= 16) { ed.lblPasswordMatch->setText(""); ed.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); } else { - ed.lblPasswordMatch->setText(tr("Passwords don't match or You have entered too few letters (10 minimum)")); + ed.lblPasswordMatch->setText(tr("Passphrase don't match or You have entered too few letters (16 minimum)")); ed.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); } @@ -413,7 +414,7 @@ void MainWindow::encryptWallet() { void MainWindow::removeWalletEncryption() { QDialog d(this); - Ui_encryptionDialog ed; + Ui_removeencryption ed; ed.setupUi(&d); // Handle edits on the password box @@ -475,8 +476,6 @@ void MainWindow::removeWalletEncryption() { FileEncryption::decrypt(target_decwallet_file, target_encwallet_file, key); FileEncryption::decrypt(target_decaddr_file, target_encaddr_file, key); - - } } diff --git a/src/removeencryption.ui b/src/removeencryption.ui index fb923db..15f4f30 100644 --- a/src/removeencryption.ui +++ b/src/removeencryption.ui @@ -1,10 +1,8 @@ - - - - - Dialog - - + + + removeencryption + + 0 0 @@ -12,40 +10,168 @@ 300 - - Dialog + + Remove your Wallet encryption - - + + - 30 - 240 + 50 + 260 341 32 - + Qt::Horizontal - + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + 260 + 170 + 133 + 23 + + + + <html><head/><body><p>16 letters minimum</p></body></html> + + + + + + 10 + 229 + 157 + 25 + + + + Confirm Passphrase: + + + + + + 10 + 164 + 382 + 3 + + + + Qt::Horizontal + + + + + + 173 + 229 + 219 + 25 + + + + QLineEdit::Password + + + + + + 10 + 56 + 382 + 56 + + + + <html><head/><body><p><span style=" font-size:14pt; color:#ef2929;">WARNING:</span> If yo remove your encryption, all your Data is Plaintext on your Disk!</p></body></html> + + + Qt::AlignCenter + + + true + + + + + + 10 + 260 + 382 + 3 + + + + Qt::Horizontal + + + + + + 10 + 198 + 157 + 25 + + + + Encryption Passphrase: + + + + + + 10 + 175 + 243 + 17 + + + + color: red; + + + Passphrase don't match + + + Qt::AlignCenter + + + + + + 173 + 198 + 219 + 25 + + + + QLineEdit::Password + + - buttonBox accepted() - Dialog + removeencryption accept() - + 248 254 - + 157 274 @@ -54,14 +180,14 @@ buttonBox rejected() - Dialog + removeencryption reject() - + 316 260 - + 286 274 @@ -69,4 +195,3 @@ -