50 throw std::runtime_error(
"Error calling rand_s.");
54 std::ifstream randomGeneratorFile(
"/dev/urandom", std::ios::binary);
56 if (randomGeneratorFile.is_open()) {
58 randomGeneratorFile.close();
62 throw std::runtime_error(
"Error opening /dev/urandom.");
114 output.
SetBit(numberOfBits - 1);
118 #if 0//start disabled code block
146 output.
SetBit(numberOfBits - 1);
157 if (output.
GetSize() != length) {
161 while (
true == retry);
162 #endif//end disabled code block
BigIntegerBase< T_Impl > & SetBit(const size_t index)
Sets a bit in the current instance at the specified index.
BigIntegerBase< T_Impl > GetNextPrime() const
Computes the first prime greater than the current instance.
static void Destroy(RandomProviderBase< RandomProviderGmp > &input)
Destroys the underlying data from input.
T_Impl::RandomGeneratorState randomGeneratorState
Implementation-defined random generator state.
Definition of class RandomProviderGmp.
static void Initialize(RandomProviderBase< RandomProviderGmp > &input)
Initializes the underlying random state from input.
bool IsPrime() const
Tests if the current instance is a prime number.
BigInteger GetRandomInteger(const size_t numberOfBits)
Generates a random integer having at most numberOfBits bits.
size_t GetSize(const unsigned int base=2) const
Gets the length of the integer in the specified base.
T_Impl::BigIntegerType data
Implementation-defined big integer variable.
Template class which masks various RandomProvider implementations and provides a common interface tha...
Template class which adds syntactic sugar to big integer operations.
static void GetRandomInteger(BigIntegerBase< BigIntegerGmp > &output, RandomProviderBase< RandomProviderGmp > &input, const size_t numberOfBits)
Generates a random integer having at most numberOfBits bits.
unsigned int randomSeed
Random seed required for the random generator state initialization.
static void GetMaxLengthRandomPrime(BigIntegerBase< BigIntegerGmp > &output, RandomProviderBase< RandomProviderGmp > &input, const size_t numberOfBits)
Generates a random prime, guaranteed to have numberOfBits length.