Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
914195c
Init commit,'generateRSAkey()' returns a 'keyPair' and log it to console
edcedcedcedc May 27, 2025
3e67c5e
Add decode function for private key
edcedcedcedc May 28, 2025
6ba694d
Copy 'generateRandomIV()' from a cherry-pick commit from 'init-test...'
edcedcedcedc May 28, 2025
81d0fcd
'encodePrivateKey' implimentation without testing
edcedcedcedc May 28, 2025
1d21d65
Add new UI buttons and rearrange them in 'test ui'
edcedcedcedc May 29, 2025
7c38999
Display RSA pair within UI and update 'qdebug()'
edcedcedcedc May 29, 2025
38c8d6f
WIP segmentation error
edcedcedcedc Jun 2, 2025
9b0bff6
Fix segmentation error, dynamic memory allocation
edcedcedcedc Jun 3, 2025
b43c189
Add const qualifier
edcedcedcedc Jun 3, 2025
8678eaf
Display encoded private key in the UI
edcedcedcedc Jun 5, 2025
832a6e5
WIP 'decodePrivateKey()' 'decryptAES_CBC()' and other changes
edcedcedcedc Jun 5, 2025
4642f84
Fix resize for 'ciphertext' and 'plaintext'
edcedcedcedc Jun 6, 2025
5c9f925
WIP show in debug log that init privat key matches decoded private key
edcedcedcedc Jun 6, 2025
0193ca4
Fix memory leaks, update UI messages
edcedcedcedc Jun 9, 2025
61e6df2
Init autotests and brief for rsa pair
edcedcedcedc Jun 9, 2025
c8d6de7
Merge branch 'gsoc2025' into feature-rsa-keypair-generation
edcedcedcedc Jun 10, 2025
990b7a1
Fix merge bugs and rename the parameter for 'decodeMasterKey()'
edcedcedcedc Jun 10, 2025
42c83ee
Fix another merge bugs, add masterKey to param of encode and decode p…
edcedcedcedc Jun 10, 2025
fbb7c0a
Remove '= nullptr' from QByteArray variables
edcedcedcedc Jun 10, 2025
4946ef0
Implement autotest functions
edcedcedcedc Jun 10, 2025
053533f
Remove 'qDebug()' and comments
edcedcedcedc Jun 11, 2025
056cfaa
cherry-pick Init commit,'generateRSAkey()' returns a 'keyPair' and lo…
edcedcedcedc May 27, 2025
8521574
Generate session key, encrypt and decrypt it
edcedcedcedc Jun 12, 2025
2a2fcbc
Switch '//test' to '//TODO'
edcedcedcedc Jun 13, 2025
18145c4
Rename Encode/Decode to Encrypt/Decrypt add if stataments to the UI
edcedcedcedc Jun 13, 2025
e481e29
Show encryption and decryption of the session key in the UI
edcedcedcedc Jun 13, 2025
bab2953
Some if statements to avoid minor errors in the UI
edcedcedcedc Jun 13, 2025
b4e139c
Add autotests for session key encryption decryption and generation
edcedcedcedc Jun 13, 2025
9030fae
Redundancy cleanup in encryp decrypt test for rsa key pair
edcedcedcedc Jun 16, 2025
ca2e2a4
Add AES_CBC_128 for encryption and decryptions switch previous AES_CB…
edcedcedcedc Jun 16, 2025
5311d57
Encrypt decrypt messages using AES_CBC_128
edcedcedcedc Jun 16, 2025
bb31d92
Change label names from encode decode to encryp decrypt message
edcedcedcedc Jun 16, 2025
909d126
Update error messages and show encryption decryption in qdebug
edcedcedcedc Jun 16, 2025
3edac4d
Display in the UI
edcedcedcedc Jun 16, 2025
72bb7bd
Read from mTextEdit and clear() after user clicks encrypt message
edcedcedcedc Jun 16, 2025
5e622a9
Doxygen for some functions
edcedcedcedc Jun 17, 2025
e4a0d5f
Autotests and if statements to improve the UI
edcedcedcedc Jun 23, 2025
001daae
Reset functionality and cleanup
edcedcedcedc Jun 23, 2025
6a06481
Merge branch 'feature-session-key-generation' into integration-phase-1
edcedcedcedc Jun 27, 2025
8757c86
Merge branch 'feature-message-decrypt-encrypt-using-session-key' into…
edcedcedcedc Jun 27, 2025
1a1fd1d
Some renaming after merge and small fixes
edcedcedcedc Jun 30, 2025
0aea4d2
Cli entry point, login programmatically, upload/download key (without…
edcedcedcedc Jul 17, 2025
2bfd122
Remove .txt cred file and add cred to .env update the func
edcedcedcedc Jul 23, 2025
0a18268
Mv and rename e2ekeytool to encryptiontestcli, update CMakeLists, and…
edcedcedcedc Jul 28, 2025
04c3946
Refactor the files to use them for tests, upload/download rsa keypair…
edcedcedcedc Aug 1, 2025
92e8606
Coding style fixes and const in 'encryptionutils' 'encryptiontestgui'
edcedcedcedc Aug 4, 2025
3f58196
Remove unused includes, header files from add_executable add copyrigh…
edcedcedcedc Aug 4, 2025
ed7b588
Rm 'ruqolaencryptiondebug.cpp'
edcedcedcedc Aug 4, 2025
ec98e06
Fix linking issue for the test, spot and spot a runtime bug
edcedcedcedc Aug 4, 2025
b8ab123
Fix tests, fix variables, remove spaces, add qualifiers
edcedcedcedc Aug 8, 2025
c061b17
Fix small 'auto' bug again
edcedcedcedc Aug 11, 2025
749e27a
Add e2e db and e2e db tests, WIP undefined reference
edcedcedcedc Aug 14, 2025
8013d83
Remove qdebug from 'restapiabstractjob.cpp'
edcedcedcedc Aug 15, 2025
3b89bfe
Add nodiscard attribute to function declarations
edcedcedcedc Aug 15, 2025
56dac26
Fix undefined reference bug, big thx to Laurent Montel
edcedcedcedc Aug 15, 2025
32d42dd
Fix testNonexistentKey
edcedcedcedc Aug 15, 2025
a2ad0a3
Extend login manager to accept multiple credentials
edcedcedcedc Aug 17, 2025
9dc9469
Session key distribution .h .cpp and tests .h .cpp
edcedcedcedc Aug 18, 2025
56b8563
Fix '[[nodiscard]]' to make methods more explicit that they are retur…
edcedcedcedc Aug 20, 2025
7bacacf
Added the export macro the class header to make it available outside …
edcedcedcedc Aug 20, 2025
3f55e89
Update the docs and coding style
edcedcedcedc Aug 20, 2025
4d4ca9c
Session key distribution, code style fix, autotests for 'ProvideUsers…
edcedcedcedc Aug 20, 2025
f8e1177
Remove duplicate class, fix compile with strict compile flags, add co…
edcedcedcedc Aug 21, 2025
41932a7
Build provideuserswithsuggestedgroupkeysjob.cpp
edcedcedcedc Aug 21, 2025
8fb106d
WIP session key distribution integration test segmentation fail
edcedcedcedc Aug 21, 2025
a873992
WIP 'auth settings is empty'
edcedcedcedc Aug 21, 2025
282fd7e
Rm integration tests, keep autotests and update
edcedcedcedc Aug 22, 2025
8230c9d
Export RSA public key and docstrings and UI update
edcedcedcedc Sep 16, 2025
84cd7e0
Switch pepper to salt as Aaron Ogle recommended to avoid confusion in…
edcedcedcedc Sep 16, 2025
1aa6c20
Add export encrypted private key, add more test ui, add readme
edcedcedcedc Sep 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ compile_commands.json
/.vscode/
.qtcreator/
.env
compose.yml
docker-compose.yml
3 changes: 3 additions & 0 deletions src/apps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# SPDX-FileCopyrightText: 2020-2025 Laurent Montel <montel@kde.org>
# SPDX-License-Identifier: BSD-3-Clause

include(ECMAddAppIcon)

add_executable(ruqola main.cpp)
Expand All @@ -11,6 +12,7 @@ target_link_libraries(ruqola
KF6::XmlGui
KF6::IconThemes
)

if(USE_DBUS)
target_link_libraries(ruqola KF6::DBusAddons)
else()
Expand All @@ -25,3 +27,4 @@ ecm_add_app_icon(appIcons ICONS "${RUQOLA_ICONS}")
target_sources(ruqola PRIVATE ${appIcons})

install(TARGETS ruqola ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})

7 changes: 6 additions & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,8 @@ target_sources(libruqolacore PRIVATE
servererrorinfohistorymanager.cpp
servererrorinfohistorymanager.h



localdatabase/localmessagelogger.cpp
localdatabase/localmessagelogger.h

Expand All @@ -526,10 +528,13 @@ target_sources(libruqolacore PRIVATE

localdatabase/localdatabasebase.h
localdatabase/localdatabasebase.cpp

localdatabase/localaccountdatabase.h
localdatabase/localaccountdatabase.cpp

localdatabase/e2ekeystore.h
localdatabase/e2ekeystore.cpp

localdatabase/globaldatabase.h
localdatabase/globaldatabase.cpp

Expand Down
36 changes: 35 additions & 1 deletion src/core/autotests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# SPDX-FileCopyrightText: 2020-2025 Laurent Montel <montel@kde.org>
# SPDX-FileCopyrightText: 2020-2025 Laurent Montel <montel@kde.org>,
# SPDX-FileCopyrightText: 2025 Andro Ranogajec <ranogaet@gmail.com>
# SPDX-License-Identifier: BSD-3-Clause
add_definitions(-DRUQOLA_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data")
add_definitions(-DRUQOLA_BINARY_DATA_DIR="${CMAKE_CURRENT_BINARY_DIR}/data")
Expand Down Expand Up @@ -167,6 +168,38 @@ add_ruqola_test(textconvertertest.cpp)
if(USE_E2E_SUPPORT)
add_ruqola_test(encryptionutilstest.cpp)
add_ruqola_test(masterkeytest.cpp)
add_ruqola_test(rsapairtest.cpp)
add_ruqola_test(sessionkeytest.cpp)
add_ruqola_test(messageencryptiondecryptiontest.cpp)
add_ruqola_test(uploaddownloadrsakeypairtest.cpp)
add_ruqola_test(sessionkeydistributiontest.cpp)


target_sources(sessionkeydistributiontest PRIVATE
${CMAKE_SOURCE_DIR}/tests/encryptiontest/loginmanager.cpp
${CMAKE_SOURCE_DIR}/tests/encryptiontest/envutils.cpp
${CMAKE_SOURCE_DIR}/tests/encryptiontest/uploaddownloadrsakeypair.cpp
)

target_include_directories(sessionkeydistributiontest PRIVATE
${CMAKE_SOURCE_DIR}/tests/encryptiontest
${CMAKE_SOURCE_DIR}/src/core/encryption)

target_include_directories(uploaddownloadrsakeypairtest PRIVATE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it

${CMAKE_SOURCE_DIR}/tests/encryptiontest
${CMAKE_SOURCE_DIR}/src/core/encryption
${CMAKE_SOURCE_DIR}/src/rocketchatrestapi-qt
${CMAKE_SOURCE_DIR}/src/rocketchatrestapi-qt/e2e
${CMAKE_BINARY_DIR}/src/core
${CMAKE_BINARY_DIR}/src/rocketchatrestapi-qt
)

target_sources(uploaddownloadrsakeypairtest PRIVATE
${CMAKE_SOURCE_DIR}/tests/encryptiontest/loginmanager.cpp
${CMAKE_SOURCE_DIR}/tests/encryptiontest/uploaddownloadrsakeypair.cpp
${CMAKE_SOURCE_DIR}/tests/encryptiontest/envutils.cpp
)

endif()

add_ruqola_test(channelstest.cpp)
Expand All @@ -184,3 +217,4 @@ add_ruqola_test(actionbuttonsmanagertest.cpp)
add_ruqola_test(previewcommandtest.cpp)
add_ruqola_test(previewcommandutilstest.cpp)


5 changes: 5 additions & 0 deletions src/core/autotests/masterkeytest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ MasterKeyTest::MasterKeyTest(QObject *parent)
/**
* @brief This methods to going to test the determinism of the master key.
*
* n, n1 = salt
*
* m1, m2 = password
*
* if
*
* n == n1 and m == m1
* then
* getMasterKey(n, m) == getMasterKey(n1, m1)
Expand Down
41 changes: 41 additions & 0 deletions src/core/autotests/messageencryptiondecryptiontest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
SPDX-FileCopyrightText: 2025 Andro Ranogajec <ranogaet@gmail.com>

SPDX-License-Identifier: LGPL-2.0-or-later
*/

#include "messageencryptiondecryptiontest.h"
#include "encryption/encryptionutils.h"
#include <QTest>

QTEST_GUILESS_MAIN(MessageEncryptionDecryptionTest)
MessageEncryptionDecryptionTest::MessageEncryptionDecryptionTest(QObject *parent)
: QObject(parent)
{
}

/**
* @brief Tests symmetric encryption and decryption of a message using a session key.
*
* Verifies that for a message `m` and session key `k`, decryption function `D`
* and encryption function `E` the property holds:
*
* `D(E(m, k), k) = m`
*/
void MessageEncryptionDecryptionTest::messageEncryptionDecryptionTest()
{
auto message = QStringLiteral("This is GSoC 2025, Andro Ranogajec got to the end of 'Phase 1' :)");
const QByteArray sessionKey1 = EncryptionUtils::generateSessionKey();
const QByteArray sessionKey2 = EncryptionUtils::generateSessionKey();
QString decryptedMessage = QString::fromUtf8(EncryptionUtils::decryptMessage(EncryptionUtils::encryptMessage(message.toUtf8(), sessionKey1), sessionKey1));
QVERIFY(message == decryptedMessage);

for (int i = 1; i <= 10; ++i) {
QByteArray message = EncryptionUtils::generateRandomText(i).toUtf8();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const where necessary

QByteArray encrypted = EncryptionUtils::encryptMessage(message, sessionKey1);
QByteArray decryptedWithWrongKey = EncryptionUtils::decryptMessage(encrypted, sessionKey2);
QVERIFY(decryptedWithWrongKey.isEmpty() && decryptedWithWrongKey != message);
}
}

#include "moc_messageencryptiondecryptiontest.cpp"
20 changes: 20 additions & 0 deletions src/core/autotests/messageencryptiondecryptiontest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
SPDX-FileCopyrightText: 2025 Andro Ranogajec <ranogaet@gmail.com>

SPDX-License-Identifier: LGPL-2.0-or-later
*/

#pragma once

#include <QObject>

class MessageEncryptionDecryptionTest : public QObject
{
Q_OBJECT
public:
explicit MessageEncryptionDecryptionTest(QObject *parent = nullptr);
~MessageEncryptionDecryptionTest() override = default;

private Q_SLOTS:
void messageEncryptionDecryptionTest();
};
70 changes: 70 additions & 0 deletions src/core/autotests/rsapairtest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
SPDX-FileCopyrightText: 2025 Andro Ranogajec <ranogaet@gmail.com>

SPDX-License-Identifier: LGPL-2.0-or-later
*/

#include "rsapairtest.h"
#include "encryption/encryptionutils.h"
#include <QTest>

QTEST_GUILESS_MAIN(RsaPairTest)
RsaPairTest::RsaPairTest(QObject *parent)
: QObject(parent)
{
}

void RsaPairTest::rsaPairGenerationNonDeterminismTest()
{
EncryptionUtils::RSAKeyPair rsaPair1;
EncryptionUtils::RSAKeyPair rsaPair2;

for (int i = 0; i <= 10; i++) {
rsaPair1 = EncryptionUtils::generateRSAKey();
rsaPair2 = EncryptionUtils::generateRSAKey();
QVERIFY(rsaPair1.publicKey != rsaPair2.publicKey);
QVERIFY(rsaPair1.privateKey != rsaPair2.privateKey);
}
}

/**
* @brief Tests the determinism of private key encryption and decryption using the master key.
*
* Definitions:
* - x = master key
*
* - y = initial private key
*
* - z = encrypt(x, y) = encrypted private key
*
* - w = decrypt(x, z) = decrypted private key
*
* The test verifies:
*
* If the same master key x and private key y are used,
* then decrypting the encrypted key yields the original key:
*
* - decrypt(x, encrypt(x, y)) = y = initial private key
*
* In other words, w = y iff x and y are unchanged.
*/
void RsaPairTest::encryptDecryptDeterminismTest()
{
EncryptionUtils::RSAKeyPair rsaPair;
QByteArray privateKey;
QByteArray masterKey;
QByteArray encryptedPrivateKey;
QByteArray decryptedPrivateKey;

for (int i = 0; i <= 10; i++) {
rsaPair = EncryptionUtils::generateRSAKey();
privateKey = rsaPair.privateKey;
masterKey = EncryptionUtils::getMasterKey(EncryptionUtils::generateRandomText(32), EncryptionUtils::generateRandomText(32));
encryptedPrivateKey = EncryptionUtils::encryptPrivateKey(rsaPair.privateKey, masterKey);
decryptedPrivateKey = EncryptionUtils::decryptPrivateKey(encryptedPrivateKey, masterKey);

QVERIFY(decryptedPrivateKey == privateKey);
}
}

#include "moc_rsapairtest.cpp"
22 changes: 22 additions & 0 deletions src/core/autotests/rsapairtest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

/*
SPDX-FileCopyrightText: 2025 Andro Ranogajec <ranogaet@gmail.com>

SPDX-License-Identifier: LGPL-2.0-or-later
*/

#pragma once

#include <QObject>

class RsaPairTest : public QObject
{
Q_OBJECT
public:
explicit RsaPairTest(QObject *parent = nullptr);
~RsaPairTest() override = default;

private Q_SLOTS:
void rsaPairGenerationNonDeterminismTest();
void encryptDecryptDeterminismTest();
};
Loading