Compare commits

...
Author SHA1 Message Date
dranik 92bae7a5af remove debug SEC logs from secureQSettings 2026-09-28 13:47:05 +03:00
dranik dd43c4d394 fix: binary-safe file save on android, keychain timeout log 2026-09-28 13:25:44 +03:00
MrMirDan e2aab67e96 fix: first launch backup import 2026-09-23 13:24:32 +03:00
MrMirDan 2b5ff1c649 update: encrypt data before save in file 2026-09-22 18:17:17 +03:00
MrMirDan 4e19af15c0 fixes: variuos fixes 2026-09-22 11:07:17 +03:00
MrMirDan d088725436 fix: removed extra lines 2026-09-18 17:56:47 +03:00
MrMirDan 5efc3604da fix: removed extra enc indicator and Sec backup field, changed how password saved 2026-09-18 17:07:45 +03:00
MrMirDan f2f283f171 rebase on dev 2026-09-18 16:51:34 +03:00
MrMirDan 83b4fce156 fix: fixed file encryption invoke 2026-09-18 16:50:46 +03:00
MrMirDan bc575c30ca some fixes 2026-09-18 16:50:38 +03:00
MrMirDan 8b1dd214b1 fix: restoring from encrypted backup 2026-09-18 16:49:52 +03:00
MrMirDan 26e2eaca38 update: changed encryption to aes-256-gcm 2026-09-18 16:49:43 +03:00
MrMirDan 563beb4980 update: systemController 2026-09-18 16:45:14 +03:00
MrMirDan 6da2514fdc update: text and some fixes 2026-09-18 16:44:26 +03:00
MrMirDan c75cafcdfa fix: correctly save password on set or change 2026-09-18 16:43:35 +03:00
MrMirDan da8becfb6f update: files encrypt on export and files data decrypt on import 2026-09-18 16:42:20 +03:00
MrMirDan 6c9553c518 update: encryption/decryption logic, backup encryption on save and decryption on restore 2026-09-18 16:41:07 +03:00
MrMirDan 3eb131a22d update: ui to set/change password and hint 2026-09-18 16:38:26 +03:00
MrMirDan 46d8c3eab8 update: changed password and hint saving 2026-09-18 16:36:31 +03:00
MrMirDan c3c3a9af16 update: changed logic, added to settingsController 2026-09-18 16:35:57 +03:00
MrMirDan 86e69a7977 removed unnecessary method 2026-09-18 16:35:44 +03:00
MrMirDan fbcc7f85db feat: file password protection v1 2026-09-18 16:35:44 +03:00
MrMirDan 5c87e40552 update: added "Hint" text to password confirm page 2026-09-18 16:35:44 +03:00
MrMirDan 823601ab3e update: remade EncryptionIndicator 2026-09-18 16:35:44 +03:00
MrMirDan c4287564d7 fix: textField image become bigger when error text visible 2026-09-18 16:35:44 +03:00
MrMirDan 0eff02bf3c update: hint text 2026-09-18 16:35:44 +03:00
MrMirDan d72af47f61 fix: Sec/ field added to backup 2026-09-18 16:35:32 +03:00
MrMirDan 40d4be9fdf fix: restoring from encrypted backup 2026-09-18 16:35:26 +03:00
MrMirDan 84adb54927 update: changed encryption to aes-256-gcm 2026-09-18 16:35:26 +03:00
MrMirDan 479feea8bc update: app password and encription pages margins 2026-09-18 16:35:25 +03:00
MrMirDan 1a14b651a2 update: systemController 2026-09-18 16:35:25 +03:00
MrMirDan abab817f2c update: text and RU translation 2026-09-18 16:35:19 +03:00
MrMirDan f2c6b237e7 update: text 2026-09-18 16:34:39 +03:00
MrMirDan 8d18c1ba71 updated: added encryption docs links 2026-09-18 16:34:30 +03:00
MrMirDan 2b1a79fcbe update: text and some fixes 2026-09-18 16:34:28 +03:00
MrMirDan e3b9cf10f9 fix: correctly save password on set or change 2026-09-18 16:34:17 +03:00
MrMirDan 9db1bb5af7 update: added encryption indicator on backup, share and api configs pages 2026-09-18 16:33:50 +03:00
MrMirDan f7aa69c4bf update: logging page text 2026-09-18 16:33:37 +03:00
MrMirDan 16078b9b3e update: files encrypt on export and files data decrypt on import 2026-09-18 16:33:35 +03:00
MrMirDan 1d8dd3f17f update: encryption/decryption logic, backup encryption on save and decryption on restore 2026-09-18 16:33:00 +03:00
MrMirDan 45f5d82bbb update: ui to set/change password and hint 2026-09-18 16:31:31 +03:00
MrMirDan d1aca856b6 update: changed password and hint saving 2026-09-18 16:31:18 +03:00
MrMirDan 00b91e3a0b update: changed logic, added to settingsController 2026-09-18 16:31:04 +03:00
MrMirDan 0ed3ae1f63 removed unnecessary method 2026-09-18 16:30:15 +03:00
MrMirDan b926477ade feat: file password protection v1 2026-09-18 16:30:15 +03:00
35 changed files with 1469 additions and 24 deletions

No files matched your search

@@ -44,6 +44,7 @@ import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
import java.io.File
import java.io.IOException
import java.io.OutputStream
import kotlin.LazyThreadSafetyMode.NONE
import kotlin.coroutines.CoroutineContext
import kotlin.text.RegexOption.IGNORE_CASE
@@ -733,6 +734,16 @@ class AmneziaActivity : QtActivity() {
@Suppress("unused")
fun saveFile(fileName: String, data: String) {
Log.d(TAG, "Save file $fileName")
createFile(fileName) { os -> os.bufferedWriter().use { it.write(data) } }
}
@Suppress("unused")
fun saveFileBytes(fileName: String, data: ByteArray) {
Log.d(TAG, "Save file $fileName, ${data.size} bytes")
createFile(fileName) { os -> os.write(data) }
}
private fun createFile(fileName: String, write: (OutputStream) -> Unit) {
mainScope.launch {
Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
@@ -745,9 +756,7 @@ class AmneziaActivity : QtActivity() {
it?.data?.let { uri ->
Log.v(TAG, "Save file to $uri")
try {
contentResolver.openOutputStream(uri)?.use { os ->
os.bufferedWriter().use { it.write(data) }
}
contentResolver.openOutputStream(uri)?.use { os -> write(os) }
} catch (e: IOException) {
Log.e(TAG, "Failed to save file $uri: $e")
// todo: send error to Qt
+1 -1
View File
@@ -194,7 +194,7 @@ void CoreController::initControllers()
m_importController = new ImportUiController(m_importCoreController, this);
setQmlContextProperty("ImportController", m_importController);
m_exportUiController = new ExportUiController(m_exportController, this);
m_exportUiController = new ExportUiController(m_exportController, m_settingsController, this);
setQmlContextProperty("ExportController", m_exportUiController);
m_languageUiController = new LanguageUiController(m_settingsController, m_languageModel, this);
@@ -197,6 +197,31 @@ void SettingsController::clearSettings()
toggleAutoStart(false);
}
bool SettingsController::isFileEncryptionEnabled()
{
return m_appSettingsRepository->isFileEncryption();
}
void SettingsController::setPassword(QString pwd)
{
m_appSettingsRepository->setPassword(pwd);
}
QString SettingsController::getPassword()
{
return m_appSettingsRepository->getPassword();
}
void SettingsController::setHint(QString hint)
{
m_appSettingsRepository->setHint(hint);
}
QString SettingsController::getHint()
{
return m_appSettingsRepository->getHint();
}
bool SettingsController::isAutoConnectEnabled() const
{
return m_appSettingsRepository->isAutoConnect();
@@ -45,6 +45,14 @@ public:
void clearSettings();
bool isFileEncryptionEnabled();
void setPassword(QString pwd);
QString getPassword();
void setHint(QString hint);
QString getHint();
bool isAutoConnectEnabled() const;
void toggleAutoConnect(bool enable);
@@ -344,6 +344,29 @@ void SecureAppSettingsRepository::setStrictKillSwitchEnabled(bool enabled)
setValue("Conf/strictKillSwitchEnabled", enabled);
}
bool SecureAppSettingsRepository::isFileEncryption() const
{
return m_settings->hasPassword();
}
QString SecureAppSettingsRepository::getPassword() const
{
return m_settings->getPassword();
}
void SecureAppSettingsRepository::setPassword(const QString &pwd)
{
m_settings->setPassword(pwd);
}
QString SecureAppSettingsRepository::getHint() const
{
return m_settings->getHint();
}
void SecureAppSettingsRepository::setHint(const QString &hint)
{
m_settings->setHint(hint);
}
bool SecureAppSettingsRepository::isAutoConnect() const
{
return value("Conf/autoConnect", false).toBool();
@@ -70,6 +70,12 @@ public:
void setKillSwitchEnabled(bool enabled);
bool isStrictKillSwitchEnabled() const;
void setStrictKillSwitchEnabled(bool enabled);
bool isFileEncryption() const;
QString getPassword() const;
void setPassword(const QString &pwd);
QString getHint() const;
void setHint(const QString &hint);
bool isAutoConnect() const;
void setAutoConnect(bool enabled);
+3
View File
@@ -0,0 +1,3 @@
<svg width="10" height="11" viewBox="0 0 10 11" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2.5 5V3C2.5 2.33696 2.76339 1.70107 3.23223 1.23223C3.70107 0.763392 4.33696 0.5 5 0.5C5.66304 0.5 6.29893 0.763392 6.76777 1.23223C7.23661 1.70107 7.5 2.33696 7.5 3V5M1.5 5H8.5C9.05229 5 9.5 5.44772 9.5 6V9.5C9.5 10.0523 9.05229 10.5 8.5 10.5H1.5C0.947715 10.5 0.5 10.0523 0.5 9.5V6C0.5 5.44772 0.947715 5 1.5 5Z" stroke="#EB5757" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 494 B

+3
View File
@@ -0,0 +1,3 @@
<svg width="10" height="11" viewBox="0 0 10 11" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2.5 5.00252V3.00252C2.49938 2.38254 2.72914 1.78445 3.14469 1.32435C3.56023 0.864252 4.13191 0.574969 4.74875 0.512663C5.36559 0.450356 5.98357 0.61947 6.48274 0.987175C6.9819 1.35488 7.32663 1.89494 7.45 2.50252M1.5 5.00252H8.5C9.05229 5.00252 9.5 5.45023 9.5 6.00252V9.50252C9.5 10.0548 9.05229 10.5025 8.5 10.5025H1.5C0.947715 10.5025 0.5 10.0548 0.5 9.50252V6.00252C0.5 5.45023 0.947715 5.00252 1.5 5.00252Z" stroke="#5CAEE7" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 592 B

+2
View File
@@ -42,6 +42,8 @@
<file>controls/home.svg</file>
<file>controls/infinity.svg</file>
<file>controls/info.svg</file>
<file>controls/lock-locked.svg</file>
<file>controls/lock-unlocked.svg</file>
<file>controls/mail.svg</file>
<file>controls/map-pin.svg</file>
<file>controls/more-vertical.svg</file>
@@ -161,6 +161,21 @@ void AndroidController::saveFile(const QString &fileName, const QString &data)
QJniObject::fromString(data).object<jstring>());
}
void AndroidController::saveFile(const QString &fileName, const QByteArray &data)
{
QJniEnvironment env;
const jsize size = static_cast<jsize>(data.size());
jbyteArray bytes = env->NewByteArray(size);
if (!bytes) {
qCritical() << "AndroidController::saveFile: cannot allocate byte array of size" << size;
return;
}
env->SetByteArrayRegion(bytes, 0, size, reinterpret_cast<const jbyte *>(data.constData()));
callActivityMethod("saveFileBytes", "(Ljava/lang/String;[B)V",
QJniObject::fromString(fileName).object<jstring>(), bytes);
env->DeleteLocalRef(bytes);
}
QString AndroidController::openFile(const QString &filter)
{
QEventLoop wait;
@@ -33,6 +33,7 @@ public:
void stop();
void resetLastServer(int serverIndex);
void saveFile(const QString &fileName, const QString &data);
void saveFile(const QString &fileName, const QByteArray &data);
QString openFile(const QString &filter);
int getFd(const QString &fileName);
void closeFd();
+63 -2
View File
@@ -11,6 +11,11 @@
#include <QRandomGenerator>
#include <QSharedPointer>
#include <QTimer>
#include <QFile>
#include <openssl/evp.h>
#include <openssl/rand.h>
#include <openssl/err.h>
using namespace QKeychain;
@@ -118,6 +123,31 @@ void SecureQSettings::remove(const QString &key)
m_cache.remove(key);
}
bool SecureQSettings::hasSecTag(const QString &tag) const
{
auto job = QSharedPointer<ReadPasswordJob>(new ReadPasswordJob(keyChainName), &QObject::deleteLater);
job->setAutoDelete(false);
job->setKey(tag);
QEventLoop loop;
QObject::connect(job.data(), &ReadPasswordJob::finished, &loop, &QEventLoop::quit);
job->start();
loop.exec();
if (job->error() == QKeychain::EntryNotFound)
return false;
if (job->error()) {
qCritical() << "SecureQSettings::hasSecTag Error:" << job->errorString();
return false;
}
return !job->binaryData().isEmpty();
}
QByteArray SecureQSettings::backupAppConfig() const
{
QMutexLocker locker(&m_mutex);
@@ -173,6 +203,31 @@ bool SecureQSettings::restoreAppConfig(const QByteArray &json)
return true;
}
bool SecureQSettings::hasPassword() const
{
return hasSecTag("password");
}
void SecureQSettings::setPassword(const QString &password)
{
setSecTag("password", password.toUtf8());
}
QString SecureQSettings::getPassword() const
{
return QString::fromUtf8(getSecTag("password"));
}
void SecureQSettings::setHint(const QString &hint)
{
setSecTag("hint", hint.toUtf8());
}
QString SecureQSettings::getHint() const
{
return QString::fromUtf8(getSecTag("hint"));
}
void SecureQSettings::clearSettings()
{
QMutexLocker locker(&m_mutex);
@@ -291,11 +346,17 @@ void SecureQSettings::setSecTag(const QString &tag, const QByteArray &data)
job->setBinaryData(data);
QEventLoop loop;
QTimer::singleShot(1000, &loop, SLOT(quit()));
job->connect(job.data(), &WritePasswordJob::finished, job.data(), [&loop]() { loop.quit(); });
bool finished = false;
job->connect(job.data(), &WritePasswordJob::finished, job.data(), [&loop, &finished]() {
finished = true;
loop.quit();
});
job->start();
loop.exec();
if (job->error()) {
if (!finished) {
qCritical() << "SecureQSettings::setSecTag: keychain write timed out for tag" << tag;
} else if (job->error()) {
qCritical() << "SecureQSettings::setSecTag Error:" << job->errorString();
}
}
+10
View File
@@ -21,9 +21,19 @@ public:
void setValue(const QString &key, const QVariant &value);
void remove(const QString &key);
bool hasSecTag(const QString &tag) const;
QByteArray backupAppConfig() const;
bool restoreAppConfig(const QByteArray &json);
bool hasPassword() const;
void setPassword(const QString &password);
QString getPassword() const;
void setHint(const QString &hint);
QString getHint() const;
void clearSettings();
private:
@@ -115,6 +115,16 @@ bool SubscriptionUiController::exportNativeConfig(const QString &serverId, const
return false;
}
if (m_settingsController->isFileEncryptionEnabled()) {
const QByteArray data = nativeConfig.toUtf8();
const QByteArray encryptedData = SystemController::encryptData(data, m_settingsController->getPassword(), m_settingsController->getHint());
if (encryptedData.isEmpty())
return false;
nativeConfig = QString::fromLatin1(encryptedData.toBase64());
}
const bool saved = SystemController::saveFile(fileName, nativeConfig);
getAccountInfo(serverId, true);
return saved;
@@ -5,9 +5,10 @@
#include "../systemController.h"
#include "core/utils/qrCodeUtils.h"
ExportUiController::ExportUiController(ExportController* exportController, QObject *parent)
ExportUiController::ExportUiController(ExportController* exportController, SettingsController* settingsController, QObject *parent)
: QObject(parent),
m_exportController(exportController)
m_exportController(exportController),
m_settingsController(settingsController)
{
connect(m_exportController, &ExportController::revokeFinished, this, [this](ErrorCode errorCode) {
if (errorCode == ErrorCode::NoError) {
@@ -94,6 +95,21 @@ QList<QString> ExportUiController::getQrCodes()
void ExportUiController::exportConfig(const QString &fileName)
{
if (m_settingsController->isFileEncryptionEnabled()) {
QByteArray data = m_config.toUtf8();
QByteArray encryptedData = SystemController::encryptData(data, m_settingsController->getPassword(), m_settingsController->getHint());
if (encryptedData.isEmpty()) {
qInfo() << "ExportUiController::exportConfig: encryption failed";
return;
}
if (!SystemController::saveFile(fileName, encryptedData))
qInfo() << "ExportUiController::exportConfig: save or share was cancelled or failed";
return;
}
if (!SystemController::saveFile(fileName, m_config)) {
qInfo() << "ExportUiController::exportConfig: save or share was cancelled or failed";
}
@@ -4,13 +4,16 @@
#include <QObject>
#include "core/controllers/selfhosted/exportController.h"
#include "core/controllers/settingsController.h"
#include "core/utils/errorCodes.h"
class ExportUiController : public QObject
{
Q_OBJECT
public:
explicit ExportUiController(ExportController* exportController, QObject *parent = nullptr);
explicit ExportUiController(ExportController *exportController,
SettingsController *settingsController,
QObject *parent = nullptr);
Q_PROPERTY(QList<QString> qrCodes READ getQrCodes NOTIFY exportConfigChanged)
Q_PROPERTY(int qrCodesCount READ getQrCodesCount NOTIFY exportConfigChanged)
@@ -57,6 +60,7 @@ private:
void applyExportResult(const ExportController::ExportResult &result);
ExportController* m_exportController;
SettingsController* m_settingsController;
QString m_config;
QString m_nativeConfigString;
+49 -1
View File
@@ -133,7 +133,10 @@ void SettingsUiController::clearLogs()
void SettingsUiController::backupAppConfig(const QString &fileName)
{
QByteArray data = m_settingsController->backupAppConfig();
QByteArray data = isFileEncryptionEnabled()
? SystemController::encryptData(m_settingsController->backupAppConfig(), getPassword(), getHint())
: m_settingsController->backupAppConfig();
if (!SystemController::saveFile(fileName, data)) {
qInfo() << "SettingsUiController::backupAppConfig: save or share was cancelled or failed";
}
@@ -191,6 +194,51 @@ void SettingsUiController::clearSettings()
#endif
}
bool SettingsUiController::isFileEncryptionEnabled()
{
return m_settingsController->isFileEncryptionEnabled();
}
void SettingsUiController::setPassword(QString pwd)
{
m_settingsController->setPassword(pwd);
}
QString SettingsUiController::getPassword()
{
return m_settingsController->getPassword();
}
void SettingsUiController::setHint(QString hint)
{
m_settingsController->setHint(hint);
}
QString SettingsUiController::getHint()
{
return m_settingsController->getHint();
}
void SettingsUiController::setTempPassword(QString pwd)
{
tempPassword = pwd;
}
QString SettingsUiController::getTempPassword()
{
return tempPassword;
}
void SettingsUiController::setTempHint(QString hint)
{
tempHint = hint;
}
QString SettingsUiController::getTempHint()
{
return tempHint;
}
bool SettingsUiController::isAutoConnectEnabled()
{
return m_settingsController->isAutoConnectEnabled();
@@ -74,6 +74,18 @@ public slots:
bool isAutoUpdateCheckEnabled();
void toggleAutoUpdateCheckEnabled(bool enable);
bool isFileEncryptionEnabled();
void setPassword(QString pwd);
QString getPassword();
void setHint(QString hint);
QString getHint();
void setTempPassword(QString pwd);
QString getTempPassword();
void setTempHint(QString hint);
QString getTempHint();
bool isScreenshotsEnabled();
void toggleScreenshotsEnabled(bool enable);
@@ -139,7 +151,12 @@ signals:
void autoStartChanged();
void startMinimizedChanged();
void changingPassword();
private:
QString tempPassword;
QString tempHint;
SettingsController* m_settingsController;
ServersController* m_serversController;
};
+306 -1
View File
@@ -11,6 +11,125 @@
#include <QUrl>
#include <QtConcurrent>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/rand.h>
namespace
{
constexpr int SALT_LEN = 16;
constexpr int IV_LEN = 12;
constexpr int KEY_LEN = 32;
constexpr int TAG_LEN = 16;
constexpr int PBKDF2_ITER = 100000;
const QByteArray magicString { "EncData" };
static QString opensslErrString()
{
unsigned long e = ERR_get_error();
if (!e)
return QStringLiteral("Unknown OpenSSL error");
char buf[256];
ERR_error_string_n(e, buf, sizeof(buf));
return QString::fromUtf8(buf);
}
static bool deriveKey(const QByteArray &password, const QByteArray &salt, QByteArray &outKey)
{
outKey.resize(KEY_LEN);
const int ok = PKCS5_PBKDF2_HMAC(
password.constData(), password.size(), reinterpret_cast<const unsigned char *>(salt.constData()),
salt.size(), PBKDF2_ITER, EVP_sha256(), KEY_LEN, reinterpret_cast<unsigned char *>(outKey.data()));
if (ok != 1) {
qDebug() << "PBKDF2 failed:" << opensslErrString();
outKey.clear();
return false;
}
return true;
}
static bool aesCrypt(const QByteArray &in, const QByteArray &key, const QByteArray &iv, QByteArray &out,
QByteArray &tag, bool encrypt)
{
std::unique_ptr<EVP_CIPHER_CTX, void (*)(EVP_CIPHER_CTX *)> ctx { EVP_CIPHER_CTX_new(), EVP_CIPHER_CTX_free };
if (!ctx) {
qDebug() << "EVP_CIPHER_CTX_new failed";
return false;
}
const EVP_CIPHER *cipher = EVP_aes_256_gcm();
if (EVP_CipherInit_ex(ctx.get(), cipher, nullptr, nullptr, nullptr, encrypt ? 1 : 0) != 1) {
qDebug() << opensslErrString();
return false;
}
if (EVP_CIPHER_CTX_ctrl(ctx.get(), EVP_CTRL_GCM_SET_IVLEN, iv.size(), nullptr) != 1) {
qDebug() << opensslErrString();
return false;
}
if (EVP_CipherInit_ex(ctx.get(), nullptr, nullptr, reinterpret_cast<const unsigned char *>(key.constData()),
reinterpret_cast<const unsigned char *>(iv.constData()), -1)
!= 1) {
qDebug() << opensslErrString();
return false;
}
out.resize(in.size());
int outLen = 0;
if (EVP_CipherUpdate(ctx.get(), reinterpret_cast<unsigned char *>(out.data()), &outLen,
reinterpret_cast<const unsigned char *>(in.constData()), in.size())
!= 1) {
qDebug() << opensslErrString();
return false;
}
int finalLen = 0;
if (encrypt) {
if (EVP_CipherFinal_ex(ctx.get(), reinterpret_cast<unsigned char *>(out.data()) + outLen, &finalLen) != 1) {
qDebug() << opensslErrString();
return false;
}
out.resize(outLen + finalLen);
tag.resize(TAG_LEN);
if (EVP_CIPHER_CTX_ctrl(ctx.get(), EVP_CTRL_GCM_GET_TAG, TAG_LEN, tag.data()) != 1) {
qDebug() << opensslErrString();
return false;
}
} else {
if (tag.size() != TAG_LEN) {
qDebug() << "Invalid GCM tag size:" << tag.size();
return false;
}
if (EVP_CIPHER_CTX_ctrl(ctx.get(), EVP_CTRL_GCM_SET_TAG, TAG_LEN, const_cast<char *>(tag.constData())) != 1) {
qDebug() << opensslErrString();
return false;
}
if (EVP_CipherFinal_ex(ctx.get(), reinterpret_cast<unsigned char *>(out.data()) + outLen, &finalLen) != 1) {
qDebug() << "Authentication failed:" << opensslErrString();
return false;
}
out.resize(outLen + finalLen);
}
return true;
}
}
#ifdef Q_OS_ANDROID
#include "platforms/android/android_controller.h"
#endif
@@ -37,7 +156,7 @@ bool SystemController::saveFile(const QString &fileName, const QString &data)
bool SystemController::saveFile(const QString &fileName, const QByteArray &data)
{
#if defined Q_OS_ANDROID
AndroidController::instance()->saveFile(fileName, QString::fromUtf8(data));
AndroidController::instance()->saveFile(fileName, data);
return true;
#endif
@@ -104,6 +223,192 @@ bool SystemController::readFile(const QString &fileName, QString &data)
return true;
}
QByteArray SystemController::encryptData(const QByteArray &data, const QString &password, const QString &hint)
{
QByteArray salt(SALT_LEN, Qt::Uninitialized);
QByteArray iv(IV_LEN, Qt::Uninitialized);
QByteArray key;
QByteArray cipher;
QByteArray tag;
if (RAND_bytes(reinterpret_cast<unsigned char *>(salt.data()), SALT_LEN) != 1) {
qDebug() << "Failed to generate salt:" << opensslErrString();
return {};
}
if (RAND_bytes(reinterpret_cast<unsigned char *>(iv.data()), IV_LEN) != 1) {
qDebug() << "Failed to generate IV:" << opensslErrString();
return {};
}
if (!deriveKey(password.toUtf8(), salt, key))
return {};
if (!aesCrypt(data, key, iv, cipher, tag, true))
return {};
QByteArray result;
const QByteArray hintBytes = hint.toUtf8();
const quint32 hintLen = static_cast<quint32>(hintBytes.size());
result.reserve(magicString.size() + sizeof(hintLen) + hintBytes.size() + SALT_LEN + IV_LEN + TAG_LEN + cipher.size());
result += magicString;
result.append(reinterpret_cast<const char *>(&hintLen), sizeof(hintLen));
result += hintBytes;
result += salt;
result += iv;
result += tag;
result += cipher;
return result;
}
QByteArray SystemController::decryptData(const QByteArray &content, const QString &password)
{
if (!content.startsWith(magicString)) {
qDebug() << "Invalid file format (magic missing)";
return {};
}
qsizetype pos = magicString.size();
if (content.size() - pos < static_cast<qsizetype>(sizeof(quint32))) {
qDebug() << "Corrupted data (no hint length)";
return {};
}
quint32 hintLen = 0;
memcpy(&hintLen, content.constData() + pos, sizeof(hintLen));
pos += sizeof(hintLen);
const qsizetype hintSize = static_cast<qsizetype>(hintLen);
if (hintSize > content.size() - pos) {
qDebug() << "Corrupted data (hint truncated)";
return {};
}
pos += hintSize;
constexpr qsizetype encryptionMetadataSize = SALT_LEN + IV_LEN + TAG_LEN;
if (encryptionMetadataSize > content.size() - pos) {
qDebug() << "Corrupted data (encryption metadata truncated)";
return {};
}
const QByteArray salt = content.mid(pos, SALT_LEN);
pos += SALT_LEN;
const QByteArray iv = content.mid(pos, IV_LEN);
pos += IV_LEN;
const QByteArray tag = content.mid(pos, TAG_LEN);
pos += TAG_LEN;
const QByteArray cipher = content.mid(pos);
QByteArray key;
if (!deriveKey(password.toUtf8(), salt, key)) {
qDebug() << "Key derivation failed";
return { };
}
QByteArray plain;
QByteArray tagCopy = tag;
if (!aesCrypt(cipher, key, iv, plain, tagCopy, false)) {
qDebug() << "Decryption failed (wrong password or corrupted data)";
return {};
}
return plain;
}
QByteArray SystemController::getDecryptedData(const QString &filePath, const QString &password)
{
QFile f(filePath);
if (!f.open(QIODevice::ReadOnly)) {
qDebug() << "Cannot open file:" << f.errorString();
return {};
}
const QByteArray encryptedData = f.readAll();
f.close();
return decryptData(encryptedData, password);
}
bool SystemController::isFileEncrypted(const QString &filePath)
{
QFile f(filePath);
if (!f.open(QIODevice::ReadOnly)) {
qDebug() << "Cannot open file for read: %1", f.errorString();
return false;
}
QByteArray data = f.readAll();
f.close();
if (!data.startsWith(magicString)) {
qDebug() << "File is not recognized as encrypted (magic missing)";
return false;
}
return true;
}
bool SystemController::isPasswordValid(const QString &filePath, const QString &password)
{
QFile f(filePath);
if (!f.open(QIODevice::ReadOnly)) {
qDebug() << f.errorString();
return false;
}
const QByteArray encryptedData = f.readAll();
f.close();
if (!encryptedData.startsWith(magicString))
return false;
const QByteArray decrypted = decryptData(encryptedData, password);
return !decrypted.isNull();
}
QString SystemController::readHint(const QString &filePath)
{
QFile f(filePath);
if (!f.open(QIODevice::ReadOnly)) {
qDebug() << "Cannot open file:" << f.errorString();
return {};
}
const QByteArray data = f.readAll();
f.close();
const qsizetype pos = magicString.size();
if (data.size() < pos + static_cast<qsizetype>(sizeof(quint32))) {
qDebug() << "Corrupted encrypted file (no hint length)";
return {};
}
quint32 hintLen = 0;
memcpy(&hintLen, data.constData() + pos, sizeof(hintLen));
const qsizetype hintStart = pos + static_cast<qsizetype>(sizeof(quint32));
const qsizetype hintSize = static_cast<qsizetype>(hintLen);
if (hintSize > data.size() - hintStart) {
qDebug() << "Corrupted encrypted file (hint truncated)";
return {};
}
return QString::fromUtf8(data.constData() + hintStart, hintSize);
}
QString SystemController::getFileName(const QString &acceptLabel, const QString &nameFilter,
const QString &selectedFile, const bool isSaveMode, const QString &defaultSuffix)
{
+9
View File
@@ -15,10 +15,19 @@ public:
static bool readFile(const QString &fileName, QByteArray &data);
static bool readFile(const QString &fileName, QString &data);
static QByteArray encryptData(const QByteArray &data, const QString &password, const QString &hint);
public slots:
QString getFileName(const QString &acceptLabel, const QString &nameFilter, const QString &selectedFile = "",
const bool isSaveMode = false, const QString &defaultSuffix = "");
QByteArray decryptData(const QByteArray &content, const QString &password);
QByteArray getDecryptedData(const QString &filePath, const QString &password);
bool isFileEncrypted(const QString &filePath);
bool isPasswordValid(const QString &filePath, const QString &password);
QString readHint(const QString &filePath);
void setQmlRoot(QObject *qmlRoot);
bool isAuthenticated();
@@ -0,0 +1,86 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects
import Style 1.0
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
Rectangle {
id: root
property bool linkEnabled: false
property string textColor: AmneziaStyle.color.paleGray
property string textString
property int textFormat: Text.PlainText
property string iconPath
property real iconWidth: 16
property real iconHeight: 16
color: AmneziaStyle.color.onyxBlack
radius: 32
implicitHeight: iconHeight + 8
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
Layout.bottomMargin: 16
RowLayout {
id: content
anchors.centerIn: parent
spacing: 0
Image {
width: root.iconWidth
height: root.iconHeight
source: root.iconPath
}
CaptionTextType {
id: supportingText
Layout.fillWidth: true
Layout.leftMargin: 8
text: root.textString
textFormat: Text.RichText
color: root.textColor
}
BasicButtonType {
visible: root.linkEnabled
hoverEnabled: false
implicitHeight: root.iconHeight
implicitWidth: linkText.width/2 + 8
defaultColor: AmneziaStyle.color.transparent
CaptionTextType {
id: linkText
leftPadding: 4
width: linkText.text.length * linkText.font.pixelSize
text: qsTr("Learn more")
textFormat: Text.RichText
color: AmneziaStyle.color.goldenApricot
}
clickedFunc: function() {
Qt.openUrlExternally("https://storage.googleapis.com/amnezia/docs?m-path=/documentation/instructions/encryption")
}
}
}
}
+130
View File
@@ -0,0 +1,130 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import PageEnum 1.0
import Style 1.0
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
DrawerType2 {
id: root
objectName: "passwordDrawer"
property bool fromOutside: true
property string fileName
property var securedFunc
signal restoreSecuredBackup
signal importSecuredFile
expandedStateContent: ColumnLayout {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 16
anchors.leftMargin: 16
anchors.rightMargin: 16
Connections {
target: root
function onRestoreSecuredBackup() {
root.securedFunc = function() {
SettingsController.restoreAppConfigFromData(SystemController.getDecryptedData(fileName, passwordField.textField.text))
}
passwordDrawer.openTriggered()
}
function onImportSecuredFile() {
root.securedFunc = function() {
if (ImportController.extractConfigFromData(SystemController.getDecryptedData(fileName, passwordField.textField.text))) {
PageController.goToPage(PageEnum.PageSetupWizardViewConfig)
}
}
passwordDrawer.openTriggered()
}
}
Header2TextType {
Layout.fillWidth: true
Layout.bottomMargin: 8
text: qsTr("Password required")
}
TextFieldWithHeaderType {
id: passwordField
Connections {
target: root
function onCloseTriggered() {
passwordField.textField.text = ""
}
}
property bool hideContent: true
Layout.fillWidth: true
headerText: qsTr("Password")
textField.echoMode: hideContent ? TextInput.Password : TextInput.Normal
textField.text: textField.text
rightButtonClickedOnEnter: true
clickedFunc: function () {
hideContent = !hideContent
buttonImageSource = textField.text !== "" ? (hideContent ? "qrc:/images/controls/eye.svg" : "qrc:/images/controls/eye-off.svg") : ""
}
textField.onFocusChanged: {
textField.text = textField.text.replace(/^\s+|\s+$/g, '')
}
textField.onTextChanged: {
buttonImageSource = textField.text !== "" ? (hideContent ? "qrc:/images/controls/eye.svg" : "qrc:/images/controls/eye-off.svg") : ""
}
}
LabelTextType {
Layout.fillWidth: true
Layout.topMargin: 8
Layout.bottomMargin: 16
text: qsTr("Hint: ") + (fromOutside ? (fileName !== "" ? SystemController.readHint(fileName) : "") : SettingsController.getHint())
}
BasicButtonType {
id: doneButton
Layout.fillWidth: true
text: qsTr("Done")
clickedFunc: function() {
if (fromOutside) {
if (!SystemController.isPasswordValid(fileName, passwordField.textField.text)) {
passwordField.errorText = qsTr("Invalid password")
return
}
} else {
if (passwordField.textField.text !== SettingsController.getPassword()) {
passwordField.errorText = qsTr("Invalid password")
return
}
}
if (root.securedFunc && typeof root.securedFunc === "function") {
root.securedFunc()
}
root.closeTriggered()
}
}
}
}
@@ -219,11 +219,10 @@ Item {
leftImageSource: root.buttonImageSource
anchors.top: content.top
anchors.bottom: content.bottom
anchors.right: content.right
height: content.implicitHeight
width: content.implicitHeight
height: root.errorText !== "" ? content.implicitHeight - errorField.height - 5: content.implicitHeight
width: root.errorText !== "" ? content.implicitHeight - errorField.height - 5: content.implicitHeight
squareLeftSide: true
clickedFunc: function() {
@@ -60,6 +60,16 @@ PageType {
headerText: qsTr("Configuration Files")
descriptionText: qsTr("For router setup or the AmneziaWG app")
}
EncryptionIndicator {
id: indicator
visible: SettingsController.isFileEncryptionEnabled()
linkEnabled: true
textString: qsTr("Encryption enabled.")
iconPath: "qrc:/images/controls/lock-locked.svg"
}
}
delegate: ColumnLayout {
@@ -0,0 +1,191 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import PageEnum 1.0
import Style 1.0
import "./"
import "../Controls2"
import "../Config"
import "../Controls2/TextTypes"
import "../Components"
PageType {
id: root
property bool isChangingPassword: false
BackButtonType {
id: backButton
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
onFocusChanged: {
if (this.activeFocus) {
listView.positionViewAtBeginning()
}
}
backButtonFunction: function() {
PageController.closePage()
if (root.isChangingPassword) {
root.isChangingPassword = false
}
}
}
ListViewType {
id: listView
anchors.top: backButton.bottom
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.left: parent.left
header: ColumnLayout {
width: listView.width
BaseHeaderType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
Layout.bottomMargin: 16
headerText: qsTr("Password & Encryption")
descriptionText: qsTr("Password protection for backups and configuration files.\nRequired to restore or import encrypted files.")
}
BasicButtonType {
Layout.leftMargin: 8
Layout.bottomMargin: 32
implicitHeight: 16
defaultColor: AmneziaStyle.color.transparent
hoveredColor: AmneziaStyle.color.translucentWhite
pressedColor: AmneziaStyle.color.sheerWhite
disabledColor: AmneziaStyle.color.mutedGray
textColor: AmneziaStyle.color.goldenApricot
text: qsTr("Learn more")
clickedFunc: function() {
Qt.openUrlExternally("https://storage.googleapis.com/amnezia/docs?m-path=/documentation/instructions/encryption")
}
}
EncryptionIndicator {
id: indicator
textString: qsTr("Password set. Encryption enabled")
iconPath: "qrc:/images/controls/lock-locked.svg"
}
BasicButtonType {
id: disableEncryptionButton
Layout.fillWidth: true
Layout.topMargin: 16
Layout.leftMargin: 16
Layout.rightMargin: 16
text: qsTr("Disable encryption")
clickedFunc: function() {
passwordDrawer.securedFunc = function() {
PageController.showBusyIndicator(true)
SettingsController.setPassword("")
SettingsController.setHint("")
PageController.closePage()
PageController.goToPage(PageEnum.PageSettingsAppPassword)
PageController.showBusyIndicator(false)
PageController.showNotificationMessage(qsTr("Encryption disabled"))
}
passwordDrawer.openTriggered()
}
}
BasicButtonType {
id: changePasswordButton
hoveredColor: AmneziaStyle.color.slateGray
defaultColor: AmneziaStyle.color.midnightBlack
textColor: AmneziaStyle.color.paleGray
borderWidth: 1
Layout.fillWidth: true
Layout.topMargin: 8
Layout.leftMargin: 16
Layout.rightMargin: 16
text: qsTr("Change password")
signal changingPassword
clickedFunc: function() {
passwordDrawer.securedFunc = function() {
root.isChangingPassword = true
PageController.showBusyIndicator(true)
PageController.closePage()
PageController.goToPage(PageEnum.PageSettingsAppPassword)
PageController.showBusyIndicator(false)
SettingsController.changingPassword()
}
passwordDrawer.openTriggered()
}
}
PasswordDrawer {
id: passwordDrawer
fromOutside: false
parent: root
anchors.fill: parent
expandedHeight: root.height * 0.45
securedFunc: function() {
root.isChangingPassword = true
PageController.showBusyIndicator(true)
PageController.closePage()
PageController.goToPage(PageEnum.PageSettingsAppPassword)
PageController.showBusyIndicator(false)
SettingsController.changingPassword()
}
}
}
spacing: 16
footer: ColumnLayout {
width: listView.width
CaptionTextType {
Layout.fillWidth: true
Layout.topMargin: 32
horizontalAlignment: Text.AlignHCenter
textFormat: Text.RichText
text: qsTr("If the password is forgotten, it can't be recovered. To reset the password, "
+ "<a href=\"appSettings\" style=\"text-decoration:none; color:%1;\">settings must be reset</a>."
+ "\nEncrypted files can only be opened with password used to encrypt them").arg(AmneziaStyle.color.goldenApricot)
color: AmneziaStyle.color.mutedGray
onLinkActivated: function(link) {
if (link === "appSettings") {
PageController.closePage()
}
}
}
}
}
}
@@ -0,0 +1,215 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import PageEnum 1.0
import Style 1.0
import "./"
import "../Controls2"
import "../Config"
import "../Controls2/TextTypes"
import "../Components"
PageType {
id: root
property bool isChangingPassword: false
Connections {
target: SettingsController
function onChangingPassword() {
root.isChangingPassword = true
}
}
BackButtonType {
id: backButton
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
onFocusChanged: {
if (this.activeFocus) {
listView.positionViewAtBeginning()
}
}
backButtonFunction: function() {
PageController.closePage()
if (root.isChangingPassword) {
root.isChangingPassword = false
}
}
}
ListViewType {
id: listView
anchors.top: backButton.bottom
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.left: parent.left
header: ColumnLayout {
width: listView.width
BaseHeaderType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
headerText: root.isChangingPassword ? qsTr("Change password") : qsTr("Password & Encryption")
descriptionText: root.isChangingPassword ? qsTr("Existing encrypted files will still require the old password.\nThe new password will be used for new encrypted files.")
: qsTr("Password protection for backups and configuration files.\nRequired to restore or import encrypted files.")
}
BasicButtonType {
Layout.leftMargin: 8
Layout.bottomMargin: 32
implicitHeight: 16
defaultColor: AmneziaStyle.color.transparent
hoveredColor: AmneziaStyle.color.translucentWhite
pressedColor: AmneziaStyle.color.sheerWhite
disabledColor: AmneziaStyle.color.mutedGray
textColor: AmneziaStyle.color.goldenApricot
text: qsTr("Learn more")
clickedFunc: function() {
Qt.openUrlExternally("https://storage.googleapis.com/amnezia/docs?m-path=/documentation/instructions/encryption")
}
}
EncryptionIndicator {
id: indicator
visible: !root.isChangingPassword
textString: qsTr("Password not set. Encryption disabled")
iconPath: "qrc:/images/controls/lock-unlocked.svg"
}
}
model: inputFields
spacing: 16
delegate: ColumnLayout {
width: listView.width
TextFieldWithHeaderType {
id: delegate
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
headerText: title
textField.echoMode: hideContent ? TextInput.Password : TextInput.Normal
textField.placeholderText: placeholderContent
textField.text: textField.text
rightButtonClickedOnEnter: true
clickedFunc: function () {
clickedHandler()
buttonImageSource = textField.text !== "" ? imageSource : ""
}
textField.onFocusChanged: {
textField.text = textField.text.replace(/^\s+|\s+$/g, '')
}
textField.onTextChanged: {
buttonImageSource = textField.text !== "" ? imageSource : ""
}
}
}
footer: ColumnLayout {
width: listView.width
BasicButtonType {
id: continueButton
Layout.fillWidth: true
Layout.topMargin: 32
Layout.leftMargin: 16
Layout.rightMargin: 16
text: qsTr("Continue")
clickedFunc: function() {
if (!root.isPasswordProperlyFilled()) {
return
}
var _password = listView.itemAtIndex(vars.passwordIndex).children[0].textField.text
var _hint = listView.itemAtIndex(vars.hintIndex).children[0].textField.text
SettingsController.setTempPassword(_password)
SettingsController.setTempHint(_hint)
PageController.goToPage(PageEnum.PageSettingsAppPasswordConfirm)
if (root.isChangingPassword) {
SettingsController.changingPassword()
}
}
}
}
}
function isPasswordProperlyFilled() {
var tooShort = false
var secretDataItem = listView.itemAtIndex(vars.passwordIndex).children[0]
if (secretDataItem.textField.text === "") {
secretDataItem.errorText = qsTr("Password cannot be empty")
tooShort = true
} else if (secretDataItem.textField.text.length < 4) {
secretDataItem.errorText = qsTr("Password too short")
tooShort = true
}
return !tooShort
}
property list<QtObject> inputFields: [
passwordObject,
hintObject
]
QtObject {
id: passwordObject
property string title: root.isChangingPassword ? qsTr("New password") : qsTr("Set encryption password")
readonly property string placeholderContent: ""
property string imageSource: "qrc:/images/controls/eye.svg"
property bool hideContent: true
readonly property var clickedHandler: function() {
hideContent = !hideContent
imageSource = hideContent ? "qrc:/images/controls/eye.svg" : "qrc:/images/controls/eye-off.svg"
}
}
QtObject {
id: hintObject
property string title: root.isChangingPassword ? qsTr("New password hint (optional)") : qsTr("Password hint")
readonly property string placeholderContent: ""
property string imageSource: ""
property bool hideContent: false
readonly property var clickedHandler: undefined
}
QtObject {
id: vars
readonly property int passwordIndex: 0
readonly property int hintIndex: 1
}
}
@@ -0,0 +1,158 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import PageEnum 1.0
import Style 1.0
import "./"
import "../Controls2"
import "../Config"
import "../Controls2/TextTypes"
PageType {
id: root
property bool isChangingPassword: false
property bool isSaving: false
Connections {
target: SettingsController
function onChangingPassword() {
root.isChangingPassword = true
}
}
BackButtonType {
id: backButton
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 20
onFocusChanged: {
if (this.activeFocus) {
listView.positionViewAtBeginning()
}
}
}
ListViewType {
id: listView
anchors.top: backButton.bottom
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.left: parent.left
header: ColumnLayout {
width: listView.width
BaseHeaderType {
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
headerText: root.isChangingPassword ? qsTr("Confirm new password") : qsTr("Confirm password")
descriptionText: root.isChangingPassword ? qsTr("") : qsTr("If the password is forgotten, it cant be recovered. "
+ "To reset the password, the app settings must be reset.\n"
+ "Encrypted files can only be opened with the password used to encrypt them")
}
}
model: 1 // fake model
spacing: 16
delegate: ColumnLayout {
width: listView.width
TextFieldWithHeaderType {
id: delegate
property bool hideContent: true
Layout.fillWidth: true
Layout.topMargin: 16
Layout.leftMargin: 16
Layout.rightMargin: 16
headerText: root.isChangingPassword ? qsTr("Re-enter new password") : qsTr("Re-enter password")
textField.echoMode: hideContent ? TextInput.Password : TextInput.Normal
textField.placeholderText: ""
textField.text: textField.text
rightButtonClickedOnEnter: true
clickedFunc: function () {
hideContent = !hideContent
buttonImageSource = textField.text !== "" ? (hideContent ? "qrc:/images/controls/eye.svg" : "qrc:/images/controls/eye-off.svg") : ""
}
textField.onFocusChanged: {
textField.text = textField.text.replace(/^\s+|\s+$/g, '')
}
textField.onTextChanged: {
buttonImageSource = textField.text !== "" ? (hideContent ? "qrc:/images/controls/eye.svg" : "qrc:/images/controls/eye-off.svg") : ""
}
}
}
footer: ColumnLayout {
width: listView.width
LabelTextType {
Layout.fillWidth: true
Layout.topMargin: 16
Layout.leftMargin: 16
Layout.rightMargin: 16
Layout.bottomMargin: 24
text: qsTr("Hint: ") + SettingsController.getTempHint()
}
BasicButtonType {
id: continueButton
Layout.fillWidth: true
Layout.leftMargin: 16
Layout.rightMargin: 16
text: root.isChangingPassword ? qsTr("Save new password") : qsTr("Turn on encryption")
clickedFunc: function() {
if (root.isSaving || !root.isPasswordProperlyFilled()) {
return
}
root.isSaving = true
SettingsController.setPassword(SettingsController.getTempPassword())
SettingsController.setHint(SettingsController.getTempHint())
SettingsController.setTempPassword("")
SettingsController.setTempHint("")
root.isSaving = false
PageController.closePage()
PageController.goToPage(PageEnum.PageSettings)
PageController.goToPage(PageEnum.PageSettingsAppEncryption)
PageController.showNotificationMessage(qsTr("Encryption enabled"))
}
}
}
}
function isPasswordProperlyFilled() {
var notMatch = false
var secretDataItem = listView.itemAtIndex(0).children[0]
if (secretDataItem.textField.text !== SettingsController.getTempPassword()) {
secretDataItem.errorText = qsTr("Passwords not match")
notMatch = true
}
return !notMatch
}
}
@@ -234,6 +234,23 @@ PageType {
DividerType {}
LabelWithButtonType {
id: labelWithButtonAppPassword
Layout.fillWidth: true
text: qsTr("Password & Encryption")
descriptionText: qsTr("Password protection for backups and configuration files")
rightImageSource: "qrc:/images/controls/chevron-right.svg"
clickedFunction: function() {
SettingsController.isFileEncryptionEnabled() ? PageController.goToPage(PageEnum.PageSettingsAppEncryption)
: PageController.goToPage(PageEnum.PageSettingsAppPassword)
}
}
DividerType {}
LabelWithButtonType {
id: labelWithButtonLogging
+21 -1
View File
@@ -69,6 +69,16 @@ PageType {
headerText: qsTr("Back up your configuration")
descriptionText: qsTr("You can save your settings to a backup file to restore them the next time you install the application.")
}
EncryptionIndicator {
id: indicator
visible: SettingsController.isFileEncryptionEnabled()
linkEnabled: true
textString: qsTr("Encryption enabled.")
iconPath: "qrc:/images/controls/lock-locked.svg"
}
}
model: 1 // fake model to force the ListView to be created without a model
@@ -147,10 +157,20 @@ PageType {
var filePath = SystemController.getFileName(qsTr("Open backup file"),
qsTr("Backup files (*.backup)"))
if (filePath !== "") {
restoreBackup(filePath)
passwordDrawer.fileName = filePath
SystemController.isFileEncrypted(filePath) ? passwordDrawer.restoreSecuredBackup() : restoreBackup(filePath)
}
}
}
PasswordDrawer {
id: passwordDrawer
parent: root
anchors.fill: parent
expandedHeight: root.height * 0.45
}
}
}
+6 -6
View File
@@ -48,8 +48,8 @@ PageType {
Layout.rightMargin: 16
headerText: qsTr("Logging")
descriptionText: qsTr("Enabling this function will save application's logs automatically. " +
"By default, logging functionality is disabled. Enable log saving in case of application malfunction.")
descriptionText: qsTr("Logs help diagnose app errors and connection issues" +
"Logging is disabled by default. Enable it when troubleshooting or if requested by support")
}
SwitcherType {
@@ -60,7 +60,7 @@ PageType {
Layout.leftMargin: 16
Layout.rightMargin: 16
text: qsTr("Enable logs")
text: qsTr("Enable logging")
checked: SettingsController.isLoggingEnabled
@@ -77,7 +77,7 @@ PageType {
Layout.fillWidth: true
Layout.topMargin: -8
text: qsTr("Clear logs")
text: qsTr("Delete all logs")
leftImageSource: "qrc:/images/controls/trash.svg"
isSmallLeftImage: true
@@ -154,7 +154,7 @@ PageType {
Layout.topMargin: -8
Layout.bottomMargin: -8
text: qsTr("Export logs")
text: qsTr("Save logs to file")
leftImageSource: "qrc:/images/controls/save.svg"
isSmallLeftImage: true
@@ -178,7 +178,7 @@ PageType {
QtObject {
id: clientLogs
readonly property string title: qsTr("Client logs")
readonly property string title: qsTr("App logs")
readonly property string description: qsTr("AmneziaVPN logs")
readonly property bool isVisible: true
readonly property var openLogsHandler: function() {
@@ -12,6 +12,7 @@ import "./"
import "../Controls2"
import "../Controls2/TextTypes"
import "../Config"
import "../Components"
PageType {
id: root
@@ -268,6 +269,15 @@ PageType {
}
}
PasswordDrawer {
id: passwordDrawer
parent: root
anchors.fill: parent
expandedHeight: root.height * 0.45
}
property list<QtObject> variants: [
amneziaVpn,
selfHostVpn,
@@ -327,7 +337,8 @@ PageType {
root.isRestoringBackup = true
PageController.showBusyIndicator(true)
Qt.callLater(function() {
SettingsController.restoreAppConfig(filePath)
passwordDrawer.fileName = filePath
SystemController.isFileEncrypted(filePath) ? passwordDrawer.restoreSecuredBackup() : SettingsController.restoreAppConfig(filePath)
PageController.showBusyIndicator(false)
root.isRestoringBackup = false
})
@@ -347,8 +358,13 @@ PageType {
var nameFilter = "Config files (*.vpn *.ovpn *.conf *.json)"
var fileName = SystemController.getFileName(qsTr("Open config file"), nameFilter)
if (fileName !== "") {
if (ImportController.extractConfigFromFile(fileName)) {
PageController.goToPage(PageEnum.PageSetupWizardViewConfig)
if (SystemController.isFileEncrypted(fileName)) {
passwordDrawer.fileName = fileName
passwordDrawer.importSecuredFile()
} else {
if (ImportController.extractConfigFromFile(fileName)) {
PageController.goToPage(PageEnum.PageSetupWizardViewConfig)
}
}
}
}
+10
View File
@@ -272,6 +272,16 @@ PageType {
color: AmneziaStyle.color.mutedGray
}
EncryptionIndicator {
id: indicator
visible: SettingsController.isFileEncryptionEnabled()
linkEnabled: true
textString: qsTr("Encryption enabled.")
iconPath: "qrc:/images/controls/lock-locked.svg"
}
TextFieldWithHeaderType {
id: clientNameTextField
Layout.fillWidth: true
@@ -69,6 +69,16 @@ PageType {
color: AmneziaStyle.color.mutedGray
}
EncryptionIndicator {
id: indicator
visible: SettingsController.isFileEncryptionEnabled()
linkEnabled: true
textString: qsTr("Encryption enabled.")
iconPath: "qrc:/images/controls/lock-locked.svg"
}
DropDownType {
id: serverSelector
objectName: "serverSelector"
+5
View File
@@ -4,10 +4,12 @@
<file>Components/AdLabel.qml</file>
<file>Components/ConnectButton.qml</file>
<file>Components/ConnectionTypeSelectionDrawer.qml</file>
<file>Components/EncryptionIndicator.qml</file>
<file>Components/GamepadLoader.qml</file>
<file>Components/HomeContainersListView.qml</file>
<file>Components/HomeSplitTunnelingDrawer.qml</file>
<file>Components/InstalledAppsDrawer.qml</file>
<file>Components/PasswordDrawer.qml</file>
<file>Components/QuestionDrawer.qml</file>
<file>Components/SelectLanguageDrawer.qml</file>
<file>Components/ServersListView.qml</file>
@@ -109,7 +111,10 @@
<file>Pages2/PageSettingsAbout.qml</file>
<file>Pages2/PageSettingsApiAvailableCountries.qml</file>
<file>Pages2/PageSettingsApiServerInfo.qml</file>
<file>Pages2/PageSettingsAppEncryption.qml</file>
<file>Pages2/PageSettingsApplication.qml</file>
<file>Pages2/PageSettingsAppPassword.qml</file>
<file>Pages2/PageSettingsAppPasswordConfirm.qml</file>
<file>Pages2/PageSettingsAppSplitTunneling.qml</file>
<file>Pages2/PageSettingsBackup.qml</file>
<file>Pages2/PageSettingsConnection.qml</file>
+3
View File
@@ -29,6 +29,9 @@ namespace PageLoader
PageSettingsBackup,
PageSettingsAbout,
PageSettingsLogging,
PageSettingsAppEncryption,
PageSettingsAppPassword,
PageSettingsAppPasswordConfirm,
PageSettingsSplitTunneling,
PageSettingsAppSplitTunneling,
PageSettingsKillSwitch,