added bigInt

This commit is contained in:
Andrei Yankovich 2019-07-07 21:10:09 +03:00
parent 65e5acdb1b
commit 574797fb17
6 changed files with 27 additions and 4 deletions

3
.gitmodules vendored
View File

@ -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

View File

@ -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

View File

@ -7,6 +7,8 @@
#include "qrsaencryption.h"
#include <bigint.h>
typedef unsigned __int128 uint128_t;
typedef signed __int128 int128_t;
@ -118,7 +120,7 @@ template<class INT>
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<INT>() % 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<BigInt>(pubKey, privKey)) {
return false;
}
break;
}
default:
break;
}
} while (!(keyGenRes = testKeyPair(pubKey, privKey)) && (++cnt < KEY_GEN_LIMIT));

View File

@ -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();

View File

@ -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 \

1
src/mini-gmp Submodule

@ -0,0 +1 @@
Subproject commit fa777ccb252daa4c1b4ea766ea86e6ad37ba2590