Math utils for encryption. 更多...
函数 | |
| template<typename IntType > | |
| static IntType | CalculateGCD (IntType ValueA, IntType ValueB) |
| Greatest common divisor of ValueA and ValueB. | |
| template<typename IntType > | |
| static IntType | CalculateMultiplicativeInverseOfExponent (IntType Exponent, IntType Totient) |
| Multiplicative inverse of exponent using extended GCD algorithm. 更多... | |
| template<typename IntType > | |
| static void | DecryptBytes (uint8 *DecryptedData, const IntType *Data, const int64 DataLength, const FEncryptionKey &DecryptionKey) |
| Decrypts a stream of bytes | |
| template<typename IntType > | |
| static void | EncryptBytes (IntType *EncryptedData, const uint8 *Data, const int64 DataLength, const FEncryptionKey &EncryptionKey) |
| Encrypts a stream of bytes | |
| template<typename IntType > | |
| static void | GenerateKeyPair (const IntType &P, const IntType &Q, FEncryptionKey &PublicKey, FEncryptionKey &PrivateKey) |
| Generate Key Pair for encryption and decryption. | |
| template<typename IntType > | |
| static IntType | ModularPow (IntType Base, IntType Exponent, IntType Modulus) |
| Raise Base to power of Exponent in mod Modulus. | |
Math utils for encryption.
|
static |
Multiplicative inverse of exponent using extended GCD algorithm.
Extended gcd: ax + by = gcd(a, b), where a = exponent, b = fi(n), gcd(a, b) = gcd(e, fi(n)) = 1, fi(n) is the Euler's totient function of n We only care to find d = x, which is our multiplicatve inverse of e (a).