forked from KDE/ruqola
-
Notifications
You must be signed in to change notification settings - Fork 2
Feature: End to End Encrypted Message Handling for Ruqola #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
edcedcedcedc
wants to merge
70
commits into
RocketChat:gsoc2025
Choose a base branch
from
edcedcedcedc:feature/phase2-init
base: gsoc2025
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 3e67c5e
Add decode function for private key
edcedcedcedc 6ba694d
Copy 'generateRandomIV()' from a cherry-pick commit from 'init-test...'
edcedcedcedc 81d0fcd
'encodePrivateKey' implimentation without testing
edcedcedcedc 1d21d65
Add new UI buttons and rearrange them in 'test ui'
edcedcedcedc 7c38999
Display RSA pair within UI and update 'qdebug()'
edcedcedcedc 38c8d6f
WIP segmentation error
edcedcedcedc 9b0bff6
Fix segmentation error, dynamic memory allocation
edcedcedcedc b43c189
Add const qualifier
edcedcedcedc 8678eaf
Display encoded private key in the UI
edcedcedcedc 832a6e5
WIP 'decodePrivateKey()' 'decryptAES_CBC()' and other changes
edcedcedcedc 4642f84
Fix resize for 'ciphertext' and 'plaintext'
edcedcedcedc 5c9f925
WIP show in debug log that init privat key matches decoded private key
edcedcedcedc 0193ca4
Fix memory leaks, update UI messages
edcedcedcedc 61e6df2
Init autotests and brief for rsa pair
edcedcedcedc c8d6de7
Merge branch 'gsoc2025' into feature-rsa-keypair-generation
edcedcedcedc 990b7a1
Fix merge bugs and rename the parameter for 'decodeMasterKey()'
edcedcedcedc 42c83ee
Fix another merge bugs, add masterKey to param of encode and decode p…
edcedcedcedc fbb7c0a
Remove '= nullptr' from QByteArray variables
edcedcedcedc 4946ef0
Implement autotest functions
edcedcedcedc 053533f
Remove 'qDebug()' and comments
edcedcedcedc 056cfaa
cherry-pick Init commit,'generateRSAkey()' returns a 'keyPair' and lo…
edcedcedcedc 8521574
Generate session key, encrypt and decrypt it
edcedcedcedc 2a2fcbc
Switch '//test' to '//TODO'
edcedcedcedc 18145c4
Rename Encode/Decode to Encrypt/Decrypt add if stataments to the UI
edcedcedcedc e481e29
Show encryption and decryption of the session key in the UI
edcedcedcedc bab2953
Some if statements to avoid minor errors in the UI
edcedcedcedc b4e139c
Add autotests for session key encryption decryption and generation
edcedcedcedc 9030fae
Redundancy cleanup in encryp decrypt test for rsa key pair
edcedcedcedc ca2e2a4
Add AES_CBC_128 for encryption and decryptions switch previous AES_CB…
edcedcedcedc 5311d57
Encrypt decrypt messages using AES_CBC_128
edcedcedcedc bb31d92
Change label names from encode decode to encryp decrypt message
edcedcedcedc 909d126
Update error messages and show encryption decryption in qdebug
edcedcedcedc 3edac4d
Display in the UI
edcedcedcedc 72bb7bd
Read from mTextEdit and clear() after user clicks encrypt message
edcedcedcedc 5e622a9
Doxygen for some functions
edcedcedcedc e4a0d5f
Autotests and if statements to improve the UI
edcedcedcedc 001daae
Reset functionality and cleanup
edcedcedcedc 6a06481
Merge branch 'feature-session-key-generation' into integration-phase-1
edcedcedcedc 8757c86
Merge branch 'feature-message-decrypt-encrypt-using-session-key' into…
edcedcedcedc 1a1fd1d
Some renaming after merge and small fixes
edcedcedcedc 0aea4d2
Cli entry point, login programmatically, upload/download key (without…
edcedcedcedc 2bfd122
Remove .txt cred file and add cred to .env update the func
edcedcedcedc 0a18268
Mv and rename e2ekeytool to encryptiontestcli, update CMakeLists, and…
edcedcedcedc 04c3946
Refactor the files to use them for tests, upload/download rsa keypair…
edcedcedcedc 92e8606
Coding style fixes and const in 'encryptionutils' 'encryptiontestgui'
edcedcedcedc 3f58196
Remove unused includes, header files from add_executable add copyrigh…
edcedcedcedc ed7b588
Rm 'ruqolaencryptiondebug.cpp'
edcedcedcedc ec98e06
Fix linking issue for the test, spot and spot a runtime bug
edcedcedcedc b8ab123
Fix tests, fix variables, remove spaces, add qualifiers
edcedcedcedc c061b17
Fix small 'auto' bug again
edcedcedcedc 749e27a
Add e2e db and e2e db tests, WIP undefined reference
edcedcedcedc 8013d83
Remove qdebug from 'restapiabstractjob.cpp'
edcedcedcedc 3b89bfe
Add nodiscard attribute to function declarations
edcedcedcedc 56dac26
Fix undefined reference bug, big thx to Laurent Montel
edcedcedcedc 32d42dd
Fix testNonexistentKey
edcedcedcedc a2ad0a3
Extend login manager to accept multiple credentials
edcedcedcedc 9dc9469
Session key distribution .h .cpp and tests .h .cpp
edcedcedcedc 56b8563
Fix '[[nodiscard]]' to make methods more explicit that they are retur…
edcedcedcedc 7bacacf
Added the export macro the class header to make it available outside …
edcedcedcedc 3f55e89
Update the docs and coding style
edcedcedcedc 4d4ca9c
Session key distribution, code style fix, autotests for 'ProvideUsers…
edcedcedcedc f8e1177
Remove duplicate class, fix compile with strict compile flags, add co…
edcedcedcedc 41932a7
Build provideuserswithsuggestedgroupkeysjob.cpp
edcedcedcedc 8fb106d
WIP session key distribution integration test segmentation fail
edcedcedcedc a873992
WIP 'auth settings is empty'
edcedcedcedc 282fd7e
Rm integration tests, keep autotests and update
edcedcedcedc 8230c9d
Export RSA public key and docstrings and UI update
edcedcedcedc 84cd7e0
Switch pepper to salt as Aaron Ogle recommended to avoid confusion in…
edcedcedcedc 1aa6c20
Add export encrypted private key, add more test ui, add readme
edcedcedcedc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,4 +34,4 @@ compile_commands.json | |
| /.vscode/ | ||
| .qtcreator/ | ||
| .env | ||
| compose.yml | ||
| docker-compose.yml | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove it