mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Tox datafile encryption: check
This commit is contained in:
parent
f413f14055
commit
dfd5b6411a
33
src/core.cpp
33
src/core.cpp
|
@ -1123,8 +1123,8 @@ bool Core::loadConfiguration(QString path)
|
|||
QMessageBox::warning(nullptr, tr("Password error"), tr("Failed to setup password.\nEmpty password."));
|
||||
}
|
||||
|
||||
error = tox_encrypted_load(tox, reinterpret_cast<uint8_t *>(data.data()), data.size(), pwsaltedkey, TOX_HASH_LENGTH);
|
||||
|
||||
error = tox_encrypted_load(tox, reinterpret_cast<uint8_t *>(data.data()), data.size(),
|
||||
reinterpret_cast<uint8_t *>(barePassword.data()), barePassword.size());
|
||||
if (error != 0)
|
||||
{
|
||||
QMessageBox msgb;
|
||||
|
@ -1132,6 +1132,9 @@ bool Core::loadConfiguration(QString path)
|
|||
QPushButton *cancel = msgb.addButton(tr("Change profile"), QMessageBox::RejectRole);
|
||||
QPushButton *wipe = msgb.addButton(tr("Reinit current profile"), QMessageBox::ActionRole);
|
||||
msgb.setDefaultButton(tryAgain);
|
||||
msgb.setWindowTitle(tr("Password error"));
|
||||
msgb.setText(tr("Wrong password has been entered"));
|
||||
// msgb.setInformativeText(tr(""));
|
||||
|
||||
msgb.exec();
|
||||
|
||||
|
@ -1148,8 +1151,9 @@ bool Core::loadConfiguration(QString path)
|
|||
Settings::getInstance().setEncryptTox(false);
|
||||
error = 0;
|
||||
}
|
||||
} else {
|
||||
Settings::getInstance().setEncryptTox(true);
|
||||
}
|
||||
|
||||
} while (error != 0);
|
||||
}
|
||||
}
|
||||
|
@ -1269,19 +1273,22 @@ void Core::saveConfiguration(const QString& path)
|
|||
|
||||
if (Settings::getInstance().getEncryptTox())
|
||||
{
|
||||
if (!pwsaltedkey)
|
||||
emit blockingGetPassword(tr("Tox datafile encryption password"));
|
||||
//if (!pwsaltedkey)
|
||||
// revert to unsaved...? or maybe we shouldn't even try to get a pw from here ^
|
||||
int ret = tox_encrypted_save(tox, data, pwsaltedkey, TOX_HASH_LENGTH);
|
||||
if (ret == -1)
|
||||
if (!isPasswordSet())
|
||||
{
|
||||
qCritical() << "Core::saveConfiguration: encryption of save file failed!!!";
|
||||
return;
|
||||
// probably zero chance event
|
||||
QMessageBox::warning(nullptr, tr("NO Password"), tr("Will be saved without encryption!"));
|
||||
tox_save(tox, data);
|
||||
} else {
|
||||
int ret = tox_encrypted_save(tox, data, reinterpret_cast<uint8_t *>(barePassword.data()), barePassword.size());
|
||||
if (ret == -1)
|
||||
{
|
||||
qCritical() << "Core::saveConfiguration: encryption of save file failed!!!";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
} else {
|
||||
tox_save(tox, data);
|
||||
}
|
||||
|
||||
configurationFile.write(reinterpret_cast<char *>(data), fileSize);
|
||||
configurationFile.commit();
|
||||
|
|
|
@ -151,6 +151,7 @@ void Settings::load()
|
|||
typingNotification = s.value("typingNotification", false).toBool();
|
||||
enableLogging = s.value("enableLogging", false).toBool();
|
||||
encryptLogs = s.value("encryptLogs", false).toBool();
|
||||
encryptTox = s.value("encryptTox", false).toBool();
|
||||
s.endGroup();
|
||||
|
||||
// try to set a smiley pack if none is selected
|
||||
|
@ -261,6 +262,7 @@ void Settings::save(QString path)
|
|||
s.setValue("typingNotification", typingNotification);
|
||||
s.setValue("enableLogging", enableLogging);
|
||||
s.setValue("encryptLogs", encryptLogs);
|
||||
s.setValue("encryptTox", encryptTox);
|
||||
s.endGroup();
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@ PrivacyForm::PrivacyForm() :
|
|||
bodyUI->cbTypingNotification->setChecked(Settings::getInstance().isTypingNotificationEnabled());
|
||||
bodyUI->cbKeepHistory->setChecked(Settings::getInstance().getEnableLogging());
|
||||
bodyUI->cbEncryptHistory->setChecked(Settings::getInstance().getEncryptLogs());
|
||||
bodyUI->cbEncryptHistory->setEnabled(Settings::getInstance().getEnableLogging());
|
||||
bodyUI->cbEncryptTox->setChecked(Settings::getInstance().getEncryptTox());
|
||||
|
||||
connect(bodyUI->cbTypingNotification, SIGNAL(stateChanged(int)), this, SLOT(onTypingNotificationEnabledUpdated()));
|
||||
connect(bodyUI->cbKeepHistory, SIGNAL(stateChanged(int)), this, SLOT(onEnableLoggingUpdated()));
|
||||
|
@ -125,8 +127,8 @@ void PrivacyForm::onEncryptToxUpdated()
|
|||
}
|
||||
}
|
||||
|
||||
// bodyUI->cbEncryptTox->setChecked(encrytionState);
|
||||
// Settings::getInstance().setEncryptTox(encrytionState);
|
||||
bodyUI->cbEncryptTox->setChecked(encrytionState);
|
||||
Settings::getInstance().setEncryptTox(encrytionState);
|
||||
|
||||
if (!Settings::getInstance().getEncryptLogs() && !Settings::getInstance().getEncryptTox())
|
||||
Core::getInstance()->clearPassword();
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<item>
|
||||
<widget class="QCheckBox" name="cbEncryptTox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Encrypt Tox datafile</string>
|
||||
|
|
Loading…
Reference in New Issue
Block a user