Git Product home page Git Product logo

quasarapp / qt-secret Goto Github PK

View Code? Open in Web Editor NEW
239.0 15.0 69.0 5.92 MB

Simple encryption library supporting RSA and AES algorithms.

Home Page: https://quasarapp.ddns.net:3031/docs/QuasarApp/Qt-Secret/latest/index.html

License: GNU Lesser General Public License v3.0

C++ 64.68% QMake 7.95% C 0.44% QML 18.41% CMake 8.53%
rsa aes qt cryptography algorithms alghorithm cqtdeployer library quasarapp qmake

qt-secret's Introduction

Qt-Secret Logo

Note

The OpenSSL library is better for security and performance, so we implemented a Qt wrapper library to make it easier to use. See the EasySSL library.

Fast encryption library supporting RSA and AES algorithms.

Futures

The Qt-Secret library supports the following algorithms:

RSA

The current implementation supports the following key sizes:

Supported sizes

  • RSA64
  • RSA128
  • RSA256
  • RSA512
  • RSA1024
  • RSA2048
  • RSA3072
  • RSA4096
  • RSA6144
  • RSA8192

Supported futures

  • Encryption and decryption of messages.
  • Signature and verification of the message signature.

AES

AES implementation was borrowed from bricke, because it fulfills the goals of this library.

Individual thanks bricke for implementing the AES encryption class.

AES Levels

The class supports all AES key lengths

  • AES_128
  • AES_192
  • AES_256

Modes

The class supports the following operating modes

  • ECB
  • CBC
  • CFB
  • OFB

Padding

By default the padding method is ISO, however, the class supports:

  • ZERO
  • PKCS7
  • ISO

Build

with qmake

DEFINE+=WITHOUT_GUI fot build without gui example, if you want build gui example remove this line. For build the gui example you need to install qml controls 2 in you os. Try sudo apt install qml-module-qtquick-controls2 qtdeclarative5-dev qtdeclarative5-qtquick2-plugin

  • make -j8
  • make test #(for testing)

with cmake

Include

for qmake projects

  • cd yourRepo
  • git submodule add https://github.com/QuasarApp/Qt-Secret.git # add the repository of Qt-Secret into your repo like submodule
  • git submodule update --init --recursive
  • Add to the list of libraries for the Qt-Secret assembly. For example, you can create Main.Pro in which connect Qt-Secret and your project.pro files as subprojects.

Main.pro:

TEMPLATE = subdirs
CONFIG += ordered

SUBDIRS += \
           Qt-Secret \
           MyProject
  • Include in your MyProject.pro file the pri file of Qt-Secret library
include($$PWD/../Qt-Secret/src/Qt-Secret.pri)
  • Rebuild your project

For cmake projects

  • cd yourRepo
  • git submodule add https://github.com/QuasarApp/Qt-Secret.git # add the repository of Qt-Secret into your repo like submodule
  • git submodule update --init --recursive
  • Include in your CMakeLists.txt file the main CMakeLists.txt file of Qt-Secret library
  add_subdirectory(Qt-Secret)
  target_link_libraries(MyBinary PUBLIC Qt-Secret)
  • Rebuild your project

Note

By Default Qt-Secret makes as a static library. If you want to create a shared library just add the BUILD_SHARED_LIBS into your main CMakeLists.txt file. Example :

set(BUILD_SHARED_LIBS ON)
add_subdirectory(Qt-Secret)
target_link_libraries(MyBinary PUBLIC Qt-Secret)

For other build systems

  • cd yourRepo
  • git submodule add https://github.com/QuasarApp/Qt-Secret.git # add the repository of Qt-Secret into your repo like submodule
  • git submodule update --init --recursive
  • Add the rule for build Qt-Secret
  • Add INCLUDEPATH and LIBS for your build system
  • Rebuild your project

Detailed instructions of include in QtCreator see here.

Usage

RSA

Encryption and decryption of messages.

#include <qrsaencryption.h>
#include <QDebug>

bool testEncryptAndDecryptExample() {

    QByteArray pub, priv;
    QRSAEncryption e(QRSAEncryption::Rsa::RSA_2048);
    e.generatePairKey(pub, priv); // or other rsa size

    QByteArray msg = "test message";

    auto encryptMessage = e.encode(msg, pub);

    if (encryptMessage == msg)
        return false;

    auto decodeMessage = e.decode(encryptMessage, priv);

    return decodeMessage == msg;
}

int main() {
    if (testEncryptAndDecryptExample()) {
        qInfo() << "Success!";
    }
}

Signature and verification of the message signature.

#include <qrsaencryption.h>
#include <QDebug>

bool testExample() {
    QByteArray pub, priv;
    QRSAEncryption e(QRSAEncryption::Rsa::RSA_2048);
    e.generatePairKey(pub, priv); // or other rsa size

    QByteArray msg = "test message";

    auto signedMessage = e.signMessage(msg, priv);

    if (e.checkSignMessage(signedMessage, pub)) {
        qInfo() <<" message signed success";
        return true;
    }

    return false;

}

int main() {
    if (testExample()) {
        qInfo() <<"success!";
    }
}

AES

Sample code using a 128bit key in ECB mode

#include "qaesencryption.h"

QAESEncryption encryption(QAESEncryption::AES_128, QAESEncryption::ECB);
QByteArray encodedText = encryption.encode(plainText, key);

QByteArray decodedText = encryption.decode(encodedText, key);

Example for 256bit CBC using QString

#include <QCryptographicHash>
#include "qaesencryption.h"

QAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::CBC);

QString inputStr("The Advanced Encryption Standard (AES), also known by its original name Rijndael "
                 "is a specification for the encryption of electronic data established by the U.S. "
                "National Institute of Standards and Technology (NIST) in 2001");
QString key("your-string-key");
QString iv("your-IV-vector");

QByteArray hashKey = QCryptographicHash::hash(key.toLocal8Bit(), QCryptographicHash::Sha256);
QByteArray hashIV = QCryptographicHash::hash(iv.toLocal8Bit(), QCryptographicHash::Md5);

QByteArray encodeText = encryption.encode(inputStr.toLocal8Bit(), hashKey, hashIV);
QByteArray decodeText = encryption.decode(encodeText, hashKey, hashIV);

QString decodedString = QString(encryption.removePadding(decodeText));

//decodedString == inputStr !!! 

Example via static invocation

Static invocation without creating instances, 256 bit key, ECB mode, starting from QString text/key

#include <QCryptographicHash>
#include "qaesencryption.h"

QString inputStr("The Advanced Encryption Standard (AES), also known by its original name Rijndael "
                 "is a specification for the encryption of electronic data established by the U.S. "
                "National Institute of Standards and Technology (NIST) in 2001");
QString key("your-string-key");
QString iv("your-IV-vector");

QByteArray hashKey = QCryptographicHash::hash(key.toLocal8Bit(), QCryptographicHash::Sha256);
QByteArray hashIV = QCryptographicHash::hash(iv.toLocal8Bit(), QCryptographicHash::Md5);

//Static invocation
QByteArray encrypted = QAESEncryption::Crypt(QAESEncryption::AES_256, QAESEncryption::CBC, 
                        inputStr.toLocal8Bit(), hashKey, hashIV);
//...
// Removal of Padding via Static function
QString decodedString = QString(QAESEncryption::RemovePadding(decodeText));

qt-secret's People

Contributors

endrii avatar fezar97 avatar marcelpetrick avatar miketolkachev avatar oleg-designer avatar radimkohout avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qt-secret's Issues

Adding RSA benchmarking

I run both following RSA algorithms on a Intel(R) Core(TM) i9-7920X CPU @ 2.90GHz

Here are my benchmarking (I would have appreciated to find some on the GitHub so I participate):

RSA in seconds

key size 2048 3072 4096 6144 8192
genPairKey (random process) 2.119 6.974 44.000 31.384 243.044
encode 0.062 0.170 0.437 1.489 3.470
decode 0.096 0.286 0.745 2.449 5.651
sign 1.668 5.503 13.226 44.422 104.119
checkSign 2.906 10.014 23.420 75.711 262.077

Changed data after decode

I'm encrypting QByteArray which contains some data and archive file content (zip format). After encrypt and decrypt data I can't decompress file data because the file isn't the same. I compared it binary. During encrypting I'm receiving:

When trying to encrypt data, problems arose, the last block contains non-significant zeros. These zeros will be deleted during the decryption process. For encoding and decode data with non-significant zeros use BlockSize::OneByte

I understand this problem and also Block Size::OneByte isn't a solution for me because the file's data can't be changed if we want to decompress it a success.

Is it any way to achieve encryption and decryption without losing data in this case?

AES mode not work

The RSA works fine, but I am unable to complie the AES mode, following is the error message.

main.obj:-1: error: LNK2019: unresolved external symbol "public: static struct QMetaObject const QAESEncryption::staticMetaObject" (?staticMetaObject@QAESEncryption@@2UQMetaObject@@b) referenced in function "public: static class QString __cdecl QAESEncryption::tr(char const *,char const *,int)" (?tr@QAESEncryption@@sa?AVQString@@PEBD0H@Z)

Here is my code:

#include <QCoreApplication>
#include <QCryptographicHash>
#include "qaesencryption.h"
#include <iostream>
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::CBC);

    QString inputStr("The Advanced Encryption Standard (AES), also known by its original name Rijndael "
                     "is a specification for the encryption of electronic data established by the U.S. "
                    "National Institute of Standards and Technology (NIST) in 2001");
    QString key("your-string-key");
    QString iv("your-IV-vector");

    QByteArray hashKey = QCryptographicHash::hash(key.toLocal8Bit(), QCryptographicHash::Sha256);
    QByteArray hashIV = QCryptographicHash::hash(iv.toLocal8Bit(), QCryptographicHash::Md5);

    QByteArray encodeText = encryption.encode(inputStr.toLocal8Bit(), hashKey, hashIV);
    QByteArray decodeText = encryption.decode(encodeText, hashKey, hashIV);

    QString decodedString = QString(encryption.removePadding(decodeText));
    a.quit();
}

Support protocol buffers (protobuf)

Hi,

Does anyone know if Qt-Secret is supporting the usage of protocol buffers (protobuf) ?

Because I tried to encode and decode (AES-256 CBC) a QByteArray with protobuf data and after decoding it's unable to retrieve the correct information.

Can't get it to install

When I try to get the lib installed, as described in instructions, I get this:

git submodule update --init --recursive
Submodule 'src/Qt-AES' (https://github.com/QuasarApp/Qt-AES.git) registered for path 'src/Qt-AES'
Submodule 'src/mini-gmp' (https://github.com/QuasarApp/mini-gmp.git) registered for path 'src/mini-gmp'
Cloning into '/home/ssaguiar/Qt-Secret/src/Qt-AES'...
Cloning into '/home/ssaguiar/Qt-Secret/src/mini-gmp'...
Submodule path 'src/Qt-AES': checked out '61876c7e0639eaca5588dab24c32caeae6573331'
Submodule path 'src/mini-gmp': checked out '79645f58d280cc4ca645ad35553dd2bd083c4bb1'
ssaguiar@DESKTOP-55C2EA1:~/Qt-Secret$ qmake -r
qmake: could not find a Qt installation of ''

Any clues?

Thanks

windeployqt || Unable to run exe

Thanks to this project, I can use the RSA and AES very easy.

I have created a main project which can be built good, debug good, I can run the Qt-Secret-GUI.exe in the QTCreator or debug model.

I am running it in windows 10, Microsoft Visual Studio 2019, configure with msvc2019_64
So I didn't run the following make command, any alternative cmd I can run in windows? thanks.

make -j8
make test #(for testing)

Here is my Main.pro

TEMPLATE = subdirs
CONFIG += ordered

SUBDIRS += \
           Qt-Secret \
           AppLoader

But I can't run the exported exe, I run following cmd to collect all dll files, then I open the AppLoader.exe, it can't find the QT-Secret1.dll and QtBigInt6.dll. Is there anything missing?
Thank you very much.

C:\Qt\5.15.2\msvc2019_64\bin\windeployqt D:\robot\exe\login\output\AppLoader\debug

Invalid key pairs generated

I'm using the code snippet below.
testKeyPair returns false.
I've taken testKeyPair from the private methods, as I needed to find out why the signMessage didn't work.

QByteArray pub, priv;

QRSAEncryption e;
e.generatePairKey (pub, priv, QRSAEncryption :: Rsa :: RSA_128);

if(e.testKeyPair(pub, priv))
qDebug() << "Pair valid";
else
qDebug() << "Pair invalid";

'INT' : redefinition error

I'm getting the following compile error in QT for Windows.
qrsaencryption.h:21: error: C2371: 'INT' : redefinition; different basic types

The INT type is already defined somewhere else:
C:\Program Files (x86)\Windows Kits\8.1\include\shared\minwindef.h:176

It should be a good idea to guard your code in a namespace.

Add key directory support to GUI

  • Make after #16
  • Save all generated keys in folder in home dir (default folder $HOME/.Qt-Secret)
  • Set permition for folder (access for owneruser only)
  • Add popUp or settings page for choose of secret dir.
  • Add combobox for choose of public or private keys.

Add soppot new tests

now tests check only success variants works of library, but not check not working cases.
This is especially important in verifying signatures.

get key string that works with openssl

Hi,

Is it possible to convert the keys to the format openssl needs (starting with '-----BEGIN PUBLIC KEY-----' and ending with '-----END PUBLIC KEY-----')?
I've tried to do that for some hours now, but I'm completely stuck.

Regards
Dorian

Сreate gui app (example of qt-secret)

Technical task:

  • The application must support all the functionality of the library.
    Namely :
  1. Encryption decryption (messages, files and folders)
  2. Sign and verify signatures (File and Folder Messages)
  3. Key generation

Requirement:

  • All string values ​​that will be visible to the user must be in English and wrapped in tr or qsTr for qml
  • The visual part should be written in qml
  • The application should be in the Qt-Secret / Qt-SekretCore folder
  • Qmake build system
  • Qml Style Material or Imagine
  • Primary colors repeat the colors of the qt logo.

Before doing the work, create a layout of the application design (approximate arrangement of elements on the screen), it is desirable to display each functionality on a new screen (use StackView and Drawer for an example, see gallery)

Техническое задание:

  • Приложение должно поддерживать весь функционал библиотеки.
    А именно :
  1. Шифровка дешифровка (сообщений, файлов и папок)
  2. Подпись и проверка подписей (Сообщений Файлов и папок)
  3. Генерация ключей

Требование:

  • Все строковые значения которые будут видны пользователю должны быть на Английском языке и завернуты в tr или qsTr для qml
  • Визуальная часть должна быть написана на qml
  • Приложение должно лежать в папке Qt-Secret/Qt-SekretCore
  • Система сборки qmake
  • Стиль Qml Material или Imagine
  • Основные цвета повторяют цвета логотипа qt.

Перед выполнением работ составить макет дизайна приложения (примерное расположение элементов на экране), желательно каждый функционал выводить на новый экран (использовать StackView и Drawer для примера смотри gallery)

Fix random generator

  • Now generation occurs as follows:
    longDiff - multiplicity with respect to RSA size
    int longDiff = _rsa / (sizeof (int) * 8);

    INT res = 1;

    while (longDiff > 0) {
        longDiff--;
        res *= rand() % std::numeric_limits<int>::max();
    }
  • We need to make it so that the loop repeats until res.sizeBytes becomes _rsa.
  • The old mechanism is not removed, but add the parameter that will include the new mechanism.
  • Enable only when generate prime numbers
  • Perform in a branch separated from the branch BigInt

"Private key: 03ac97b94ebae70b0c8cd6574f8f49eb79b599b67a68b73c062a477ac5be455d46ad8c20d8a542a1b2d8561ac1c67a784da185c10e0464859ed2c6144336eb1feaebd4b158155d43fd02059f2bede72b375c8cce87104075b0b070ef3f55a1389a2cf01114a3d6535e04be2d24d52d5cd1bfb3e258ba7f1fa5adcbf40610603e6a9bbd8d0c5e44dcdd6e4a6f12224747d617a15d6d502d2388e6a05186078f90b5ec40c211366f5c5cadf0a995b857d7aaf409afd004289a8632111d506530ec53e6d92d96b1f31eb1d15e7b7c4782007a04062005d242a10f5e22a07329fdce8aca38ea2f3af14bbf5ba93162b66e05d04e3b7c9a60897bf28149a8de7c0a6537ff9e66d20e7547d10c76a26fafa7ae5dfd68c0d26aff21a67b70aff3322ca0a94e7d7de06e7b50f799581d5dc7be2194f6e6b9e2ce01126acc3a24424b936e0bb2f73cf139fb12795873a56077c0ac2c2c128301a0d9e841fc73f18d14f951b8e073a5aa6e44502685013d604ea144cbdaabf11c1f554086a513d9d41c7949f35d54880511f777b08d5243de2ef201b2a2fe17f7f2b3d56f5dcb74f6020592bc49995a3f15dc6cb69ca02e10464d9b54c4d216ea35de5abcde234c81dc0d765b5a517e88b96846776806b54dc4e09d22d656754b4d68033f1e7d4a22880e245dd0d5cea6ef533728223130b951573cfebcf62220932affd6304ee060a8fe59"
"Public key: 00000000000000000000000000000000000000044c5dda87bccf2aa818991302b52354e7e74a4e28ecdb64e640b789e993a901c031e5da16b78833c2ba5639d5f1d09eb267db9eecb8ce66b967f737c1f60dc1735d92701f37c8797e070cd38adb967eebe6a4a5dfd230fd27126ed7b04d42c3c0cc806bb03b191d74d5f873b139e23582345d83a563c4f6484d12c44599383721621d46e8cb6ecf18d25f28f78e132bc29a61a45e4cc87d50af91de5de70a72a99ba85e3128f402427071b51750a0e575c4715771b56ad61e58ebae01cfd679c8b02aab6a3394413e15745d9dfa20107953321def808ece7ce815a93a88ccc2013dd2b329f1bffffffffffffd37ff9e66d20e7547d10c76a26fafa7ae5dfd68c0d26aff21a67b70aff3322ca0a94e7d7de06e7b50f799581d5dc7be2194f6e6b9e2ce01126acc3a24424b936e0bb2f73cf139fb12795873a56077c0ac2c2c128301a0d9e841fc73f18d14f951b8e073a5aa6e44502685013d604ea144cbdaabf11c1f554086a513d9d41c7949f35d54880511f777b08d5243de2ef201b2a2fe17f7f2b3d56f5dcb74f6020592bc49995a3f15dc6cb69ca02e10464d9b54c4d216ea35de5abcde234c81dc0d765b5a517e88b96846776806b54dc4e09d22d656754b4d68033f1e7d4a22880e245dd0d5cea6ef533728223130b951573cfebcf62220932affd6304ee060a8fe59"
"Test keys (3/4):"


Using on windows

Hi,
how can I use this library in qt creator on windows? I can't do it.
Thanks
Radim Kohout

Check library gmp

GitHub mirror
GMP wiki

  1. Check if it is possible to build this library on windows.
  2. Check whether the arithmetic operators for the c++ wrapper of this library are overloaded operators
  3. Unsubscribe in the task about the results of the check.

Verification of the message signature with RSA size > 2048 (4096, 8192) doesn't work correctly! Always returns false!

If you choose an RSA size greater than 2048, for example, 4098 or 8192, then after creating a signature, when verifying this signature with the public key, it always returns false (signature is false). I checked with RSA64, RSA128, RSA256, RSA512, RSA1024, RSA2048 everything works as it should, i.e. if I sign with a private key of these sizes, then when checking with a public key, the truth is returned (signature is true) as it should. But if you select 4096 or 8192, it returns false. I looked a little at what happens in the debugger and it looks like the size is recognized, and even a signature is created, but for some reason the check returns false. Perhaps when rounding or something else, bits of information are lost, I do not know for sure. But nothing is said about the size limit in 2048, so this is most likely a bug. Or I'm missing something. I'm using Win10 x64, Qt 5.15.2 (MSVC 2019 64-bit compiler). I tested through the Qt-Secret-GUI application and also in my code, the result is identical.

QRSAEncryption::randomNumber issue

There is a strange place in function INTINT QRSAEncryption::randomNumber(bool fullFill) . Variable INT res{1}; initiated with 1, and it is good, but after that there is res *= rand() % std::numeric_limits<int>::max(); and if rand() return 0, this function stuck forever. So, is it wrong behaviour in my environment, or is it bug? Best regards.

Loading keys from file

Hi,
is there any way to use keys generated by Qt-Secret, that I have load from files?
Thanks
Radim Kohout

Change the structure of RSA keys.

now the key structure is represented as
  {exponent, module}.
Need to change to:
Private Key:
  {secret exponent, prime 1, prime 2}.

Public Key:
  {public exponent, module}

Fix build

Hm. Auto tests look bad. I think I should be fixed build for ios and qt6 before merge this pull request

Originally posted by @EndrII in #95 (comment)

Cmake support

Hi,
Awesome lib!
Do you plan to support CMake anytime soon? Qt is encouraging CMake for new projects for a while now.
If you see fit I could create proper CMake files for this lib.

Thank you guys/gals

Build error for ios

I got this issue when build the project for ios on mac. Qt6.3

/Qt-Secret/src/mini-gmp/CMake/QtStaticCMake/QtStaticCMake.cmake:9: error: By not providing "FindQt5Core.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt5Core", but CMake did not find one. Could not find a package configuration file provided by "Qt5Core" with any of the following names: Qt5CoreConfig.cmake qt5core-config.cmake Add the installation prefix of "Qt5Core" to CMAKE_PREFIX_PATH or set "Qt5Core_DIR" to a directory containing one of the above files. If "Qt5Core" provides a separate development package or SDK, be sure it has been installed. extensions/Qt-Secret/src/mini-gmp/CMake/QuasarAppCITargets.cmake:123 (include) extensions/Qt-Secret/src/mini-gmp/CMake/QuasarApp.cmake:41 (include) extensions/Qt-Secret/CMakeLists.txt:15 (include)

using QRSAEncryption signMessage

Hi any way we can create Sha256withRSA using QRSaencryption ? is this posible just want to create jwt token without using ssl library

Linker error on Windows

  • OS: Windows 10
  • Qt version: 6.3.0 with MinGW
  • Build system: cmake

When building the project on Windows, I got the following errors:

23:59:17: Running steps for project Qt-Secret...
23:59:17: Persisting CMake state...
23:59:20: Starting: "C:\Qt\Tools\CMake_64\bin\cmake.exe" --build C:/Users/<username>/Documents/code/Qt/build-Qt-Secret-Desktop_Qt_6_3_0_MinGW_64_bit-Debug --target all
[1/31 2.7/sec] Building CXX object src/mini-gmp/src/CMakeFiles/QtBigint.dir/mini-gmp.c.obj
[2/31 4.0/sec] Building CXX object src/mini-gmp/src/CMakeFiles/QtBigint.dir/bigint.cpp.obj
[3/31 4.8/sec] Linking CXX static library src\mini-gmp\src\libQtBigint.a
[4/31 2.5/sec] Automatic MOC for target Qt-Secret
[5/31 2.1/sec] Automatic MOC for target QtBigintTest
[6/31 2.5/sec] Building CXX object src/mini-gmp/tests/CMakeFiles/QtBigintTest.dir/QtBigintTest_autogen/mocs_compilation.cpp.obj
[7/31 2.1/sec] Building CXX object src/CMakeFiles/Qt-Secret.dir/Qt-Secret_autogen/mocs_compilation.cpp.obj
[8/31 2.2/sec] Building CXX object src/CMakeFiles/Qt-Secret.dir/Qt-AES/qaesencryption.cpp.obj
[9/31 2.3/sec] Building CXX object src/CMakeFiles/Qt-Secret.dir/Qt-RSA/qrsaencryption.cpp.obj
[10/31 2.5/sec] Linking CXX static library src\libQt-Secret.a
[11/31 2.6/sec] Automatic MOC for target Qt-SecretTest_RSA
[12/31 2.8/sec] Building CXX object tests/CMakeFiles/Qt-SecretTest_RSA.dir/Qt-SecretTest_RSA_autogen/mocs_compilation.cpp.obj
[13/31 2.6/sec] Automatic MOC for target Qt-SecretTest_AES
[14/31 2.7/sec] Automatic MOC for target Qt-Secret-GUI
[15/31 2.9/sec] Automatic RCC for ../src/Qt-AES/res.qrc
[16/31 3.1/sec] Automatic RCC for qml.qrc
[17/31 3.2/sec] Building CXX object tests/CMakeFiles/Qt-SecretTest_AES.dir/Qt-SecretTest_AES_autogen/AUGGQPKL4Y/qrc_res.cpp.obj
[18/31 3.3/sec] Building CXX object Qt-Secret-GUI/CMakeFiles/Qt-Secret-GUI.dir/Qt-Secret-GUI_autogen/EWIEGA46WW/qrc_qml.cpp.obj
[19/31 2.9/sec] Building CXX object tests/CMakeFiles/Qt-SecretTest_RSA.dir/main.cpp.obj
[20/31 2.8/sec] Linking CXX executable tests\Qt-SecretTest_RSA.exe
FAILED: tests/Qt-SecretTest_RSA.exe 
cmd.exe /C "cd . && C:\Qt\Tools\mingw1120_64\bin\g++.exe -g  tests/CMakeFiles/Qt-SecretTest_RSA.dir/Qt-SecretTest_RSA_autogen/mocs_compilation.cpp.obj tests/CMakeFiles/Qt-SecretTest_RSA.dir/main.cpp.obj -o tests\Qt-SecretTest_RSA.exe -Wl,--out-implib,tests\libQt-SecretTest_RSA.dll.a -Wl,--major-image-version,0,--minor-image-version,0  src/libQt-Secret.a  C:/Qt/6.3.0/mingw_64/lib/libQt6Core.a  -lmpr  -luserenv  src/mini-gmp/src/libQtBigint.a  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
C:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tests/CMakeFiles/Qt-SecretTest_RSA.dir/main.cpp.obj: in function `checkKeys(QByteArray const&, QByteArray const&, QRSAEncryption::Rsa)':
C:/Users/<username>/Documents/code/Qt/Qt-Secret/tests/main.cpp:53: undefined reference to `__imp__ZN14QRSAEncryptionC1ENS_3RsaE'
C:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/<username>/Documents/code/Qt/Qt-Secret/tests/main.cpp:71: undefined reference to `__imp__ZNK14QRSAEncryption6encodeERK10QByteArrayS2_NS_9BlockSizeE'
C:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/<username>/Documents/code/Qt/Qt-Secret/tests/main.cpp:72: undefined reference to `__imp__ZNK14QRSAEncryption6decodeERK10QByteArrayS2_NS_9BlockSizeE'
C:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/<username>/Documents/code/Qt/Qt-Secret/tests/main.cpp:79: undefined reference to `__imp__ZN14QRSAEncryption11signMessageE10QByteArrayRKS0_'
C:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/<username>/Documents/code/Qt/Qt-Secret/tests/main.cpp:81: undefined reference to `__imp__ZN14QRSAEncryption16checkSignMessageERK10QByteArrayS2_'
C:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/<username>/Documents/code/Qt/Qt-Secret/tests/main.cpp:88: undefined reference to `__imp__ZN14QRSAEncryption16checkSignMessageERK10QByteArrayS2_'
C:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/<username>/Documents/code/Qt/Qt-Secret/tests/main.cpp:95: undefined reference to `__imp__ZN14QRSAEncryption16checkSignMessageERK10QByteArrayS2_'
C:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tests/CMakeFiles/Qt-SecretTest_RSA.dir/main.cpp.obj: in function `testGenesis(QRSAEncryption const&)':
C:/Users/<username>/Documents/code/Qt/Qt-Secret/tests/main.cpp:111: undefined reference to `__imp__ZNK14QRSAEncryption15generatePairKeyER10QByteArrayS1_RKS0_'
C:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/<username>/Documents/code/Qt/Qt-Secret/tests/main.cpp:112: undefined reference to `__imp__ZNK14QRSAEncryption6getRsaEv'
C:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/<username>/Documents/code/Qt/Qt-Secret/tests/main.cpp:116: undefined reference to `__imp__ZNK14QRSAEncryption15generatePairKeyER10QByteArrayS1_RKS0_'
C:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/<username>/Documents/code/Qt/Qt-Secret/tests/main.cpp:117: undefined reference to `__imp__ZNK14QRSAEncryption6getRsaEv'
C:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tests/CMakeFiles/Qt-SecretTest_RSA.dir/main.cpp.obj: in function `testCrypto(QRSAEncryption::Rsa)':
C:/Users/<username>/Documents/code/Qt/Qt-Secret/tests/main.cpp:128: undefined reference to `__imp__ZN14QRSAEncryptionC1ENS_3RsaE'
C:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/<username>/Documents/code/Qt/Qt-Secret/tests/main.cpp:134: undefined reference to `__imp__ZNK14QRSAEncryption15generatePairKeyER10QByteArrayS1_RKS0_'
C:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tests/CMakeFiles/Qt-SecretTest_RSA.dir/main.cpp.obj: in function `testExample()':
C:/Users/<username>/Documents/code/Qt/Qt-Secret/tests/main.cpp:154: undefined reference to `__imp__ZN14QRSAEncryptionC1ENS_3RsaE'
C:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/<username>/Documents/code/Qt/Qt-Secret/tests/main.cpp:155: undefined reference to `__imp__ZNK14QRSAEncryption15generatePairKeyER10QByteArrayS1_RKS0_'
C:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/<username>/Documents/code/Qt/Qt-Secret/tests/main.cpp:159: undefined reference to `__imp__ZN14QRSAEncryption11signMessageE10QByteArrayRKS0_'
C:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/<username>/Documents/code/Qt/Qt-Secret/tests/main.cpp:161: undefined reference to `__imp__ZN14QRSAEncryption16checkSignMessageERK10QByteArrayS2_'

/* Many more similar errors */

Steps

  1. git clone --recursive https://github.com/QuasarApp/Qt-Secret.git
  2. Start Qt Creator 7.0.0
  3. Double click Qt-Secret/CMakeLists.txt to open the project in Qt Creator
  4. Select Desktop Qt 6.3.0 MinGW 64-bit as the kit
  5. Click on the Build Project button (🔨)

Other observations

  • The project builds and runs successfully with set(BUILD_SHARED_LIBS ON), so its only the static library build that is failing.
  • The same steps work perfectly on Linux (Pop OS 22.04), so only the Windows build is failing.
  • I've tried with both static and dynamic versions of Qt 6.3.0, and dynamic Qt 5.15.2, but none of them works (same error).

cannot find -lQt-Secret1, cannot find -lQtBigInt6

Hi!
I downloaded src Qt-Secret, git submodule update --init --recursive, etc...
I included in my .pro-file
include($$PWD/Qt-Secret/src/Qt-Secret.pri)
but get errors:
cannot find -lQt-Secret1 and cannot find -lQtBigInt6

I try to build Qt-Secret-GUI.pro but get same error

MinGW, Qt 5.14.2
What i'm doing wrong?
Thanks!

too many errors when make

qmake -r
In file included from bigint.cpp:8:
./bigint.h:22:5: error: unexpected type name 'mpz_t': expected expression
    mpz_t data;
    ^
./bigint.h:20:28: error: variable has incomplete type 'class MINIGMPSHARED_EXPORT'
class MINIGMPSHARED_EXPORT BigInt
                           ^
./bigint.h:20:7: note: forward declaration of 'MINIGMPSHARED_EXPORT'
class MINIGMPSHARED_EXPORT BigInt
      ^
bigint.cpp:14:1: error: 'BigInt' is not a class, namespace, or enumeration
BigInt::BigInt() {
^
./bigint.h:20:28: note: 'BigInt' declared here
class MINIGMPSHARED_EXPORT BigInt
                           ^
bigint.cpp:18:1: error: 'BigInt' is not a class, namespace, or enumeration
BigInt::BigInt(const BigInt &val, int bitCount) {
^
./bigint.h:20:28: note: 'BigInt' declared here
class MINIGMPSHARED_EXPORT BigInt
                           ^
bigint.cpp:18:22: error: unknown type name 'BigInt'
BigInt::BigInt(const BigInt &val, int bitCount) {
                     ^
bigint.cpp:29:1: error: 'BigInt' is not a class, namespace, or enumeration
BigInt::BigInt(const std::string &str, int base):
^
./bigint.h:20:28: note: 'BigInt' declared here
class MINIGMPSHARED_EXPORT BigInt
                           ^

compatibility with OpenSSL etc

Is there a way to do RSA encryption that is compatible with OpenSSL, and other libraries like pycryptodome, such that RSA-encrypted messages can be exchanged with other tools?

Build for Android not working

Unable to build with android arm64-v8a

ld: error: undefined symbol: BigInt::BigInt(BigInt const&, int)

referenced by qrsaencryption.cpp
qrsaencryption.o:(eulerFunc(BigInt const&, BigInt const&))
referenced by qrsaencryption.cpp
qrsaencryption.o:(eulerFunc(BigInt const&, BigInt const&))
referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::isMutuallyPrime(BigInt const&, BigInt const&) const)
referenced 32 more times

ld: error: undefined symbol: operator-(BigInt, long long)

referenced by qrsaencryption.cpp
qrsaencryption.o:(eulerFunc(BigInt const&, BigInt const&))
referenced by qrsaencryption.cpp
qrsaencryption.o:(eulerFunc(BigInt const&, BigInt const&))
referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::generatePairKey(QByteArray&, QByteArray&, QByteArray const&) const)

ld: error: undefined symbol: operator*(BigInt, BigInt const&)

referenced by qrsaencryption.cpp
qrsaencryption.o:(eulerFunc(BigInt const&, BigInt const&))
referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::extEuclid(BigInt, BigInt) const)
referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::extEuclid(BigInt, BigInt) const)
referenced 1 more times

ld: error: undefined symbol: BigInt::~BigInt()

referenced by qrsaencryption.cpp
qrsaencryption.o:(eulerFunc(BigInt const&, BigInt const&))
referenced by qrsaencryption.cpp
qrsaencryption.o:(eulerFunc(BigInt const&, BigInt const&))
referenced by qrsaencryption.cpp
qrsaencryption.o:(eulerFunc(BigInt const&, BigInt const&))
referenced 185 more times

ld: error: undefined symbol: operator%(BigInt, long long)

referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::isMutuallyPrime(BigInt const&, BigInt const&) const)
referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::isMutuallyPrime(BigInt const&, BigInt const&) const)
referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::isMutuallyPrime(BigInt const&, BigInt const&) const)
referenced 7 more times

ld: error: undefined symbol: operator!(BigInt const&)

referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::isMutuallyPrime(BigInt const&, BigInt const&) const)
referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::isMutuallyPrime(BigInt const&, BigInt const&) const)
referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::isMutuallyPrime(BigInt const&, BigInt const&) const)
referenced 7 more times

ld: error: undefined symbol: BigInt::BigInt()

referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::isMutuallyPrime(BigInt const&, BigInt const&) const)
referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::extEuclid(BigInt, BigInt) const)
referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::extEuclid(BigInt, BigInt) const)
referenced 9 more times

ld: error: undefined symbol: BigInt::gcd(BigInt const&, BigInt const&)

referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::isMutuallyPrime(BigInt const&, BigInt const&) const)

ld: error: undefined symbol: operator==(BigInt const&, long long)

referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::isMutuallyPrime(BigInt const&, BigInt const&) const)

ld: error: undefined symbol: BigInt::sizeBits() const

referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::getBitsSize(BigInt const&) const)
referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::genesisInt(QByteArray const&, int) const)

ld: error: undefined symbol: BigInt::BigInt(long long)

referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::fromArray(QByteArray const&) const)
referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::randomNumber(bool) const)
referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::extEuclid(BigInt, BigInt) const)
referenced 4 more times

ld: error: undefined symbol: BigInt::fromHex(std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > const&)

referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::fromArray(QByteArray const&) const)
referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::genesisInt(QByteArray const&, int) const)

ld: error: undefined symbol: BigInt::getString(int) const

referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::toArray(BigInt const&, short) const)

ld: error: undefined symbol: BigInt::longBits() const

referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::randomNumber(bool) const)

ld: error: undefined symbol: operator*=(BigInt&, long long)

referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::randomNumber(bool) const)
referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::randomNumber(bool) const)

ld: error: undefined symbol: BigInt::operator++()

referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::toPrime(BigInt) const)

ld: error: undefined symbol: BigInt::isPrime(bool) const

referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::toPrime(BigInt) const)
referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::toPrime(BigInt) const)

ld: error: undefined symbol: operator+=(BigInt&, long long)

referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::toPrime(BigInt) const)

ld: error: undefined symbol: operator-=(BigInt&, long long)

referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::toPrime(BigInt) const)
referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::generatePairKey(QByteArray&, QByteArray&, QByteArray const&) const)

ld: error: undefined symbol: BigInt::BigInt(char, unsigned int, int)

referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::randomPrimeNumber(BigInt) const)
referenced by qrsaencryption.cpp
qrsaencryption.o:(QRSAEncryption::genesisInt(QByteArray const&, int) const)

ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [build/release/libQt-Secret_arm64-v8a.so] Error 1
make: *** [sub-src-Qt-Secret-pro-make_first-ordered] Error 2

potential freeze

image
With erroneous parameters, there may be a freeze, including in tests.

It is necessary to introduce a limit on the number of attempts at regeneration. (by default 10)

Fix size of sign message

At the moment the message signature uses the standard algorithm:

  1. Encrypt message m with private key and obtain signature z
  2. Combine m and z into one line {mz} and get a signed message

Signature verification:

  1. Decrypt the 2nd part of the message z and get the text m1
  2. Compare m and m1 and if they are equal, then the message is genuine.

This approach is correct but not optimized as a result of the signed message will be at least 2 times more than not signed.

  1. Read what the message signature in RSA
  2. Change alghoritm to sign hash of message.

Example:
Sign:

  1. get hash (SHA256) of message m and obtain hash Hm
  2. Encrypt Hm with private key and obtain signature z
  3. Combine m and z into one line {mz} and get a signed message

Signature verification:

  1. get hash (SHA256) of message m and obtain hash Hn
  2. Decrypt the 2nd part of the message z and get the hash Hm1
  3. Compare Hm and Hm1 and if they are equal, then the message is genuine.

too many errors about bigint when make

Mac 10.13.6
Qt version 5.14.1

qmake -r
make -j8
In file included from bigint.cpp:8:
./bigint.h:22:5: error: unexpected type name 'mpz_t': expected expression
    mpz_t data;
    ^
./bigint.h:20:28: error: variable has incomplete type 'class MINIGMPSHARED_EXPORT'
class MINIGMPSHARED_EXPORT BigInt
                           ^
./bigint.h:20:7: note: forward declaration of 'MINIGMPSHARED_EXPORT'
class MINIGMPSHARED_EXPORT BigInt
      ^
bigint.cpp:14:1: error: 'BigInt' is not a class, namespace, or enumeration
BigInt::BigInt() {
^
./bigint.h:20:28: note: 'BigInt' declared here
class MINIGMPSHARED_EXPORT BigInt
                           ^
bigint.cpp:18:1: error: 'BigInt' is not a class, namespace, or enumeration
BigInt::BigInt(const BigInt &val, int bitCount) {
^
./bigint.h:20:28: note: 'BigInt' declared here
class MINIGMPSHARED_EXPORT BigInt
                           ^
bigint.cpp:18:22: error: unknown type name 'BigInt'
BigInt::BigInt(const BigInt &val, int bitCount) {
                     ^
bigint.cpp:29:1: error: 'BigInt' is not a class, namespace, or enumeration
BigInt::BigInt(const std::string &str, int base):
^
./bigint.h:20:28: note: 'BigInt' declared here
class MINIGMPSHARED_EXPORT BigInt
                           ^

bigint.h file not found

Linux Deepin:
qrsaencryption.h#L19
#include <bigint.h> // bigint.h file not found
typedef BigInt INT; // unknown type name 'BigInt'

QRSAEncryption e(QRSAEncryption::Rsa::RSA_2048);
e.generatePairKey(pubKey.toUtf8(), key.toUtf8()); // no matching member function for call to 'generatePairKey'
QString encSecKey = e.encode(key.toUtf8(), pubKey.toUtf8());

Where is MODULUS of RSA ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.