add debugging
This commit is contained in:
@@ -516,16 +516,22 @@ void MainWindow::encryptWallet() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::removeWalletEncryption() {
|
void MainWindow::removeWalletEncryption() {
|
||||||
|
qDebug() << __func__ << ": removing wallet encryption";
|
||||||
QDialog d(this);
|
QDialog d(this);
|
||||||
Ui_removeencryption ed;
|
Ui_removeencryption ed;
|
||||||
ed.setupUi(&d);
|
ed.setupUi(&d);
|
||||||
|
|
||||||
|
qDebug() << __func__ << ": done with setupUi";
|
||||||
|
|
||||||
if (fileExists(dirwalletenc) == false) {
|
if (fileExists(dirwalletenc) == false) {
|
||||||
QMessageBox::information(this, tr("Wallet is not encrypted"),
|
QMessageBox::information(this, tr("Wallet is not encrypted"),
|
||||||
tr("Your wallet is not encrypted with a passphrase."),
|
tr("Your wallet is not encrypted with a passphrase."),
|
||||||
QMessageBox::Ok
|
QMessageBox::Ok
|
||||||
);
|
);
|
||||||
|
qDebug() << __func__ << ": wallet=" << dirwalletenc << " does NOT exist";
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
qDebug() << __func__ << ": wallet=" << dirwalletenc << " exists";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fnPasswordEdited = [=](const QString&) {
|
auto fnPasswordEdited = [=](const QString&) {
|
||||||
@@ -545,12 +551,16 @@ void MainWindow::removeWalletEncryption() {
|
|||||||
QObject::connect(ed.txtConfirmPassword, &QLineEdit::textChanged, fnPasswordEdited);
|
QObject::connect(ed.txtConfirmPassword, &QLineEdit::textChanged, fnPasswordEdited);
|
||||||
QObject::connect(ed.txtPassword, &QLineEdit::textChanged, fnPasswordEdited);
|
QObject::connect(ed.txtPassword, &QLineEdit::textChanged, fnPasswordEdited);
|
||||||
|
|
||||||
|
qDebug() << __func__ << ": connected GUI events";
|
||||||
|
|
||||||
if (d.exec() == QDialog::Accepted) {
|
if (d.exec() == QDialog::Accepted) {
|
||||||
QString passphraseBlank = ed.txtPassword->text(); // data comes from user inputs
|
QString passphraseBlank = ed.txtPassword->text(); // data comes from user inputs
|
||||||
QString passphrase = QString("HUSH3") + passphraseBlank + QString("SDL");
|
QString passphrase = QString("HUSH3") + passphraseBlank + QString("SDL");
|
||||||
|
|
||||||
int length = passphrase.length();
|
int length = passphrase.length();
|
||||||
|
|
||||||
|
qDebug() << __func__ << ": Passphrase length = " << length;
|
||||||
|
|
||||||
char *sequence = NULL;
|
char *sequence = NULL;
|
||||||
sequence = new char[length+1];
|
sequence = new char[length+1];
|
||||||
strncpy(sequence, passphrase.toUtf8(), length +1);
|
strncpy(sequence, passphrase.toUtf8(), length +1);
|
||||||
@@ -561,7 +571,6 @@ void MainWindow::removeWalletEncryption() {
|
|||||||
sequence1 = new char[length+1];
|
sequence1 = new char[length+1];
|
||||||
strncpy(sequence1, passphraseHash.toUtf8(), length+1);
|
strncpy(sequence1, passphraseHash.toUtf8(), length+1);
|
||||||
|
|
||||||
|
|
||||||
#define hash ((const unsigned char *) sequence1)
|
#define hash ((const unsigned char *) sequence1)
|
||||||
#define PASSWORD sequence
|
#define PASSWORD sequence
|
||||||
#define KEY_LEN crypto_box_SEEDBYTES
|
#define KEY_LEN crypto_box_SEEDBYTES
|
||||||
@@ -571,7 +580,7 @@ void MainWindow::removeWalletEncryption() {
|
|||||||
if (crypto_pwhash(key, sizeof key, PASSWORD, strlen(PASSWORD), hash,
|
if (crypto_pwhash(key, sizeof key, PASSWORD, strlen(PASSWORD), hash,
|
||||||
crypto_pwhash_OPSLIMIT_SENSITIVE, crypto_pwhash_MEMLIMIT_SENSITIVE, crypto_pwhash_ALG_DEFAULT) != 0) {
|
crypto_pwhash_OPSLIMIT_SENSITIVE, crypto_pwhash_MEMLIMIT_SENSITIVE, crypto_pwhash_ALG_DEFAULT) != 0) {
|
||||||
/* out of memory */
|
/* out of memory */
|
||||||
qDebug() << "crypto_pwhash failed!";
|
qDebug() << __func__ << ": crypto_pwhash failed! Possibly out of memory";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -582,32 +591,30 @@ void MainWindow::removeWalletEncryption() {
|
|||||||
|
|
||||||
FileEncryption::decrypt(target_decwallet_file, target_encwallet_file, key);
|
FileEncryption::decrypt(target_decwallet_file, target_encwallet_file, key);
|
||||||
|
|
||||||
|
|
||||||
QFile filencrypted(dirwalletenc);
|
QFile filencrypted(dirwalletenc);
|
||||||
QFile wallet(dirwallet);
|
QFile wallet(dirwallet);
|
||||||
|
|
||||||
|
qDebug() << __func__ << ": wallet size=" << wallet.size();
|
||||||
|
|
||||||
if (wallet.size() > 0) {
|
if (wallet.size() > 0) {
|
||||||
QMessageBox::information(this, tr("Wallet decryption Success"),
|
QMessageBox::information(this, tr("Wallet decryption Success"),
|
||||||
QString("Successfully delete the encryption"),
|
QString("Successfully delete the encryption"),
|
||||||
QMessageBox::Ok
|
QMessageBox::Ok
|
||||||
);
|
);
|
||||||
|
|
||||||
filencrypted.remove();
|
filencrypted.remove();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
QMessageBox::critical(this, tr("Wallet Encryption Failed"),
|
QMessageBox::critical(this, tr("Wallet Encryption Failed"),
|
||||||
QString("False password, please try again"),
|
QString("False password, please try again"),
|
||||||
QMessageBox::Ok
|
QMessageBox::Ok
|
||||||
);
|
);
|
||||||
this->removeWalletEncryption();
|
this->removeWalletEncryption();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::removeWalletEncryptionStartUp() {
|
void MainWindow::removeWalletEncryptionStartUp() {
|
||||||
|
qDebug() << __func__ << ": removing wallet encryption";
|
||||||
QDialog d(this);
|
QDialog d(this);
|
||||||
Ui_startup ed;
|
Ui_startup ed;
|
||||||
ed.setupUi(&d);
|
ed.setupUi(&d);
|
||||||
@@ -652,12 +659,14 @@ void MainWindow::removeWalletEncryptionStartUp() {
|
|||||||
|
|
||||||
unsigned char key[KEY_LEN];
|
unsigned char key[KEY_LEN];
|
||||||
|
|
||||||
if (crypto_pwhash
|
if (crypto_pwhash(key, sizeof key, PASSWORD, strlen(PASSWORD), hash,
|
||||||
(key, sizeof key, PASSWORD, strlen(PASSWORD), hash,
|
|
||||||
crypto_pwhash_OPSLIMIT_SENSITIVE, crypto_pwhash_MEMLIMIT_SENSITIVE,
|
crypto_pwhash_OPSLIMIT_SENSITIVE, crypto_pwhash_MEMLIMIT_SENSITIVE,
|
||||||
crypto_pwhash_ALG_DEFAULT) != 0) {
|
crypto_pwhash_ALG_DEFAULT) != 0) {
|
||||||
/* out of memory */
|
/* out of memory */
|
||||||
|
qDebug() << __func__ << ": crypto_pwhash failed! Possibly out of memory";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString passphraseHash1 = QByteArray(reinterpret_cast<const char*>(key), KEY_LEN).toHex();
|
QString passphraseHash1 = QByteArray(reinterpret_cast<const char*>(key), KEY_LEN).toHex();
|
||||||
DataStore::getChatDataStore()->setPassword(passphraseHash1);
|
DataStore::getChatDataStore()->setPassword(passphraseHash1);
|
||||||
|
|
||||||
@@ -668,14 +677,11 @@ void MainWindow::removeWalletEncryptionStartUp() {
|
|||||||
|
|
||||||
FileEncryption::decrypt(target_decwallet_file, target_encwallet_file, key);
|
FileEncryption::decrypt(target_decwallet_file, target_encwallet_file, key);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
|
auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
|
||||||
QFile wallet(dirwallet);
|
QFile wallet(dirwallet);
|
||||||
|
qDebug() << __func__ << ": wallet size=" << wallet.size();
|
||||||
|
|
||||||
if (wallet.size() == 0)
|
if (wallet.size() == 0) {
|
||||||
{
|
|
||||||
|
|
||||||
QMessageBox::critical(this, tr("Wallet Encryption Failed"),
|
QMessageBox::critical(this, tr("Wallet Encryption Failed"),
|
||||||
QString("false password please try again"),
|
QString("false password please try again"),
|
||||||
QMessageBox::Ok
|
QMessageBox::Ok
|
||||||
@@ -684,7 +690,6 @@ void MainWindow::removeWalletEncryptionStartUp() {
|
|||||||
}else{}
|
}else{}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
this->doClosePw();
|
this->doClosePw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user