mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-17 00:44:19 +00:00
Fix for random seeds in the RSAKey class.
This commit is contained in:
parent
942999ea31
commit
6c28b6dc18
5 changed files with 44 additions and 8 deletions
|
|
@ -5379,9 +5379,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);
|
||||
|
|
|
|||
|
|
@ -15031,7 +15031,8 @@ public:
|
|||
|
||||
The randomSeeds parameter lets you optionally pass it a set of values with
|
||||
which to seed the random number generation, improving the security of the
|
||||
keys generated.
|
||||
keys generated. If you supply these, make sure you provide more than 2 values,
|
||||
and the more your provide, the better the security.
|
||||
*/
|
||||
static void createKeyPair (RSAKey& publicKey,
|
||||
RSAKey& privateKey,
|
||||
|
|
@ -36886,38 +36887,53 @@ public:
|
|||
/**
|
||||
This structure holds a set of properties describing the current audio setup.
|
||||
|
||||
@see AudioDeviceManager::setAudioDeviceSetup()
|
||||
An AudioDeviceManager uses this class to save/load its current settings, and to
|
||||
specify your preferred options when opening a device.
|
||||
|
||||
@see AudioDeviceManager::setAudioDeviceSetup(), AudioDeviceManager::initialise()
|
||||
*/
|
||||
struct JUCE_API AudioDeviceSetup
|
||||
{
|
||||
/** Creates an AudioDeviceSetup object.
|
||||
|
||||
The default constructor sets all the member variables to indicate default values.
|
||||
You can then fill-in any values you want to before passing the object to
|
||||
AudioDeviceManager::initialise().
|
||||
*/
|
||||
AudioDeviceSetup();
|
||||
|
||||
bool operator== (const AudioDeviceSetup& other) const;
|
||||
|
||||
/** The name of the audio device used for output.
|
||||
The name has to be one of the ones listed by the AudioDeviceManager's currently
|
||||
selected device type.
|
||||
This may be the same as the input device.
|
||||
An empty string indicates the default device.
|
||||
*/
|
||||
String outputDeviceName;
|
||||
|
||||
/** The name of the audio device used for input.
|
||||
This may be the same as the output device.
|
||||
An empty string indicates the default device.
|
||||
*/
|
||||
String inputDeviceName;
|
||||
|
||||
/** The current sample rate.
|
||||
This rate is used for both the input and output devices.
|
||||
A value of 0 indicates the default rate.
|
||||
*/
|
||||
double sampleRate;
|
||||
|
||||
/** The buffer size, in samples.
|
||||
This buffer size is used for both the input and output devices.
|
||||
A value of 0 indicates the default buffer size.
|
||||
*/
|
||||
int bufferSize;
|
||||
|
||||
/** The set of active input channels.
|
||||
The bits that are set in this array indicate the channels of the
|
||||
input device that are active.
|
||||
If useDefaultInputChannels is true, this value is ignored.
|
||||
*/
|
||||
BigInteger inputChannels;
|
||||
|
||||
|
|
@ -36930,6 +36946,7 @@ public:
|
|||
/** The set of active output channels.
|
||||
The bits that are set in this array indicate the channels of the
|
||||
input device that are active.
|
||||
If useDefaultOutputChannels is true, this value is ignored.
|
||||
*/
|
||||
BigInteger outputChannels;
|
||||
|
||||
|
|
|
|||
|
|
@ -91,38 +91,53 @@ public:
|
|||
/**
|
||||
This structure holds a set of properties describing the current audio setup.
|
||||
|
||||
@see AudioDeviceManager::setAudioDeviceSetup()
|
||||
An AudioDeviceManager uses this class to save/load its current settings, and to
|
||||
specify your preferred options when opening a device.
|
||||
|
||||
@see AudioDeviceManager::setAudioDeviceSetup(), AudioDeviceManager::initialise()
|
||||
*/
|
||||
struct JUCE_API AudioDeviceSetup
|
||||
{
|
||||
/** Creates an AudioDeviceSetup object.
|
||||
|
||||
The default constructor sets all the member variables to indicate default values.
|
||||
You can then fill-in any values you want to before passing the object to
|
||||
AudioDeviceManager::initialise().
|
||||
*/
|
||||
AudioDeviceSetup();
|
||||
|
||||
bool operator== (const AudioDeviceSetup& other) const;
|
||||
|
||||
/** The name of the audio device used for output.
|
||||
The name has to be one of the ones listed by the AudioDeviceManager's currently
|
||||
selected device type.
|
||||
This may be the same as the input device.
|
||||
An empty string indicates the default device.
|
||||
*/
|
||||
String outputDeviceName;
|
||||
|
||||
/** The name of the audio device used for input.
|
||||
This may be the same as the output device.
|
||||
An empty string indicates the default device.
|
||||
*/
|
||||
String inputDeviceName;
|
||||
|
||||
/** The current sample rate.
|
||||
This rate is used for both the input and output devices.
|
||||
A value of 0 indicates the default rate.
|
||||
*/
|
||||
double sampleRate;
|
||||
|
||||
/** The buffer size, in samples.
|
||||
This buffer size is used for both the input and output devices.
|
||||
A value of 0 indicates the default buffer size.
|
||||
*/
|
||||
int bufferSize;
|
||||
|
||||
/** The set of active input channels.
|
||||
The bits that are set in this array indicate the channels of the
|
||||
input device that are active.
|
||||
If useDefaultInputChannels is true, this value is ignored.
|
||||
*/
|
||||
BigInteger inputChannels;
|
||||
|
||||
|
|
@ -135,6 +150,7 @@ public:
|
|||
/** The set of active output channels.
|
||||
The bits that are set in this array indicate the channels of the
|
||||
input device that are active.
|
||||
If useDefaultOutputChannels is true, this value is ignored.
|
||||
*/
|
||||
BigInteger outputChannels;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -92,7 +92,8 @@ public:
|
|||
|
||||
The randomSeeds parameter lets you optionally pass it a set of values with
|
||||
which to seed the random number generation, improving the security of the
|
||||
keys generated.
|
||||
keys generated. If you supply these, make sure you provide more than 2 values,
|
||||
and the more your provide, the better the security.
|
||||
*/
|
||||
static void createKeyPair (RSAKey& publicKey,
|
||||
RSAKey& privateKey,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue