diff --git a/.gitmodules b/.gitmodules index ce35a4d..e960fc7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "src/Qt-AES"] path = src/Qt-AES url = https://github.com/QuasarApp/Qt-AES.git +[submodule "src/mini-gmp"] + path = src/mini-gmp + url = https://github.com/QuasarApp/mini-gmp.git diff --git a/Qt-Secret.pro b/Qt-Secret.pro index 03329c3..3bebc71 100644 --- a/Qt-Secret.pro +++ b/Qt-Secret.pro @@ -8,13 +8,16 @@ TEMPLATE = subdirs CONFIG += ordered -SUBDIRS += src \ +SUBDIRS += \ + minigmp \ + src \ tests \ qaesencryption include($$PWD/test.pri) VERSION = 1.1.0 +minigmp.file = src/mini-gmp/GMP.pro src.file = src/Qt-Secret.pro tests.file = tests/Qt-SecretTest.pro qaesencryption.file = src/Qt-AES/qaesencryption.pro diff --git a/src/Qt-RSA/qrsaencryption.cpp b/src/Qt-RSA/qrsaencryption.cpp index aa0a72d..2ce59de 100644 --- a/src/Qt-RSA/qrsaencryption.cpp +++ b/src/Qt-RSA/qrsaencryption.cpp @@ -7,6 +7,8 @@ #include "qrsaencryption.h" +#include + typedef unsigned __int128 uint128_t; typedef signed __int128 int128_t; @@ -118,7 +120,7 @@ template INT toPrime(INT n) { if (!(n % 2)) { - n++; + ++n; } INT LN = n; @@ -204,7 +206,7 @@ bool keyGenerator(QByteArray &pubKey, QByteArray &privKey) { INT eilor = eulerFunc(p, q); INT e = randNumber() % eilor; - if (!(e % 2)) e--; + if (!(e % 2)) --e; do { e -= 2; @@ -344,6 +346,14 @@ bool QRSAEncryption::generatePairKey(QByteArray &pubKey, QByteArray &privKey, QR } break; } + case RSA_256: { + if (!keyGenerator(pubKey, privKey)) { + return false; + } + break; + } + default: + break; } } while (!(keyGenRes = testKeyPair(pubKey, privKey)) && (++cnt < KEY_GEN_LIMIT)); diff --git a/src/Qt-RSA/qrsaencryption.h b/src/Qt-RSA/qrsaencryption.h index b78ac70..d935234 100644 --- a/src/Qt-RSA/qrsaencryption.h +++ b/src/Qt-RSA/qrsaencryption.h @@ -29,7 +29,11 @@ class QRSAEncryption public: enum Rsa { RSA_64 = 64, - RSA_128 = 128 + RSA_128 = 128, + RSA_256 = 256, + RSA_512 = 512, + RSA_1024 = 1024, + RSA_2048 = 2048 }; QRSAEncryption(); diff --git a/src/Qt-Secret.pro b/src/Qt-Secret.pro index 0496e0d..c814519 100644 --- a/src/Qt-Secret.pro +++ b/src/Qt-Secret.pro @@ -21,6 +21,8 @@ CONFIG(release, debug|release): { DESTDIR="$$PWD/build/debug" } +include($$PWD/mini-gmp/GMP.pri) + VERSION = 1.1.0 HEADERS += Qt-AES/qaesencryption.h \ diff --git a/src/mini-gmp b/src/mini-gmp new file mode 160000 index 0000000..fa777cc --- /dev/null +++ b/src/mini-gmp @@ -0,0 +1 @@ +Subproject commit fa777ccb252daa4c1b4ea766ea86e6ad37ba2590