1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-20 01:14:20 +00:00

Fix for random seeds in the RSAKey class.

This commit is contained in:
Julian Storer 2010-07-06 11:39:48 +01:00
parent 942999ea31
commit 6c28b6dc18
5 changed files with 44 additions and 8 deletions

View file

@ -120,9 +120,10 @@ void RSAKey::createKeyPair (RSAKey& publicKey, RSAKey& privateKey,
const int numBits, const int* randomSeeds, const int numRandomSeeds)
{
jassert (numBits > 16); // not much point using less than this..
jassert (numRandomSeeds == 0 || numRandomSeeds >= 2); // you need to provide plenty of seeds here!
BigInteger p (Primes::createProbablePrime (numBits / 2, 30, randomSeeds, numRandomSeeds));
BigInteger q (Primes::createProbablePrime (numBits - numBits / 2, 30, randomSeeds, numRandomSeeds));
BigInteger p (Primes::createProbablePrime (numBits / 2, 30, randomSeeds, numRandomSeeds / 2));
BigInteger q (Primes::createProbablePrime (numBits - numBits / 2, 30, randomSeeds == 0 ? 0 : (randomSeeds + numRandomSeeds / 2), numRandomSeeds - numRandomSeeds / 2));
const BigInteger n (p * q);
const BigInteger m (--p * --q);