mirror of
https://github.com/QuasarApp/Qt-Secret.git
synced 2025-05-04 11:19:33 +00:00
added bigInt
This commit is contained in:
parent
65e5acdb1b
commit
574797fb17
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -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
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
|
@ -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();
|
||||
|
@ -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
1
src/mini-gmp
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit fa777ccb252daa4c1b4ea766ea86e6ad37ba2590
|
Loading…
x
Reference in New Issue
Block a user