1
0
Fork 0
forked from blue/squawk

SimpleCrypt password jamming is now optional

This commit is contained in:
Blue 2024-11-17 20:25:33 +02:00
parent 85ff6c25ba
commit 9a44ae1fa5
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
6 changed files with 62 additions and 39 deletions

View file

@ -22,6 +22,10 @@
#include <QDir>
#include <QStandardPaths>
#ifdef WITH_SIMPLE_CRYPT
#include "external/simpleCrypt/simplecrypt.h"
#endif
Core::Squawk::Squawk(QObject* parent):
QObject(parent),
accounts(),
@ -71,7 +75,6 @@ void Core::Squawk::stop() {
QSettings settings;
settings.beginGroup("core");
settings.beginWriteArray("accounts");
SimpleCrypt crypto(passwordHash);
for (std::deque<Account*>::size_type i = 0; i < accounts.size(); ++i) {
settings.setArrayIndex(i);
Account* acc = accounts[i];
@ -84,7 +87,13 @@ void Core::Squawk::stop() {
password = acc->getPassword();
break;
case Shared::AccountPassword::jammed:
password = crypto.encryptToString(acc->getPassword());
#ifdef WITH_SIMPLE_CRYPT2
password = SimpleCrypt(passwordHash).encryptToString(acc->getPassword());
#else
qDebug() << "The password for account" << acc->getName() << "is set to be jammed, but Squawk was compiled without SimpleCrypt support";
qDebug("Can not encode password, setting this account to always ask password mode");
ap = Shared::AccountPassword::alwaysAsk;
#endif
break;
default:
break;
@ -697,17 +706,24 @@ void Core::Squawk::readSettings() {
settings.value("passwordType", static_cast<int>(Shared::AccountPassword::plain)).toInt()
);
QString name = settings.value("name").toString();
QString password = settings.value("password", "").toString();
if (passwordType == Shared::AccountPassword::jammed) {
#ifdef WITH_SIMPLE_CRYPT
SimpleCrypt crypto(passwordHash);
password = crypto.decryptToString(password);
#else
qDebug() << "The password for account" << name << "is jammed, but Squawk was compiled without SimpleCrypt support";
qDebug("Can not decode password, setting this account to always ask password mode");
passwordType = Shared::AccountPassword::alwaysAsk;
#endif
}
addAccount(
settings.value("login").toString(),
settings.value("server").toString(),
password,
settings.value("name").toString(),
name,
settings.value("resource").toString(),
settings.value("active").toBool(),
passwordType

View file

@ -33,7 +33,6 @@
#include "shared/global.h"
#include "shared/info.h"
#include "shared/clientinfo.h"
#include "external/simpleCrypt/simplecrypt.h"
#include <core/components/clientcache.h>
#include <core/components/networkaccess.h>