activemq-cpp-3.6.0
decaf::security::SecureRandom Class Reference

#include <src/main/decaf/security/SecureRandom.h>

Inheritance diagram for decaf::security::SecureRandom:

Public Member Functions

 SecureRandom ()
 Creates a new instance of a secure random number generator that implements the default random number algorithm.
 SecureRandom (const std::vector< unsigned char > &seed)
 Creates a new instance of a secure random number generator that implements the default random number algorithm.
 SecureRandom (const unsigned char *seed, int size)
 Creates a new instance of a secure random number generator that implements the default random number algorithm.
virtual ~SecureRandom ()
virtual void nextBytes (std::vector< unsigned char > &buf)
 Modifies the byte array by a random sequence of bytes generated by this random number generator.
Parameters
bufnon-null array to contain the new random bytes
See Also
next

virtual void nextBytes (unsigned char *buf, int size)
 Modifies the byte array by a random sequence of bytes generated by this random number generator.
Parameters
bufnon-null array to contain the new random bytes
See Also
next
Exceptions
NullPointerExceptionif buff is NULL
IllegalArgumentExceptionif size is negative

virtual void setSeed (unsigned long long seed)
 Modifies the seed using linear congruential formula presented in The Art of Computer Programming, Volume 2, Section 3.2.1.
Parameters
seedthe seed that alters the state of the random number generator
See Also
next
Random()
#Random(long)

virtual void setSeed (const std::vector< unsigned char > &seed)
 Supplements or sets the seed of this secure random number generator, calls to this method never reduces randomness.
virtual void setSeed (const unsigned char *seed, int size)
 Supplements or sets the seed of this secure random number generator, calls to this method never reduces randomness.
- Public Member Functions inherited from decaf::util::Random
 Random ()
 Construct a random generator with the current time of day in milliseconds as the initial state.
 Random (unsigned long long seed)
 Construct a random generator with the given seed as the initial state.
virtual ~Random ()
bool nextBoolean ()
 Answers the next pseudo-random, uniformly distributed boolean value generated by this generator.
double nextDouble ()
 Generates a normally distributed random double number between 0.0 inclusively and 1.0 exclusively.
float nextFloat ()
 Generates a normally distributed random float number between 0.0 inclusively and 1.0 exclusively.
double nextGaussian ()
 Pseudo-randomly generates (approximately) a normally distributed double value with mean 0.0 and a standard deviation value of 1.0 using the polar method of G.
int nextInt ()
 Generates a uniformly distributed 32-bit int value from the this random number sequence.
int nextInt (int n)
 Returns to the caller a new pseudo-random integer value which is uniformly distributed between 0 (inclusively) and the value of n (exclusively).
long long nextLong ()
 Generates a uniformly distributed 64-bit int value from the this random number sequence.

Protected Member Functions

virtual int next (int bits)
 Answers a pseudo-random uniformly distributed int value of the number of bits specified by the argument bits as described by Donald E.Knuth in The Art of Computer Programming, Volume 2: Seminumerical Algorithms, section 3.2.1.
Returns
int a pseudo-random generated int number
Parameters
bitsnumber of bits of the returned value
See Also
nextBytes
nextDouble
nextFloat
nextInt()
nextInt(int)
nextGaussian
nextLong

Detailed Description

Since
1.0

Constructor & Destructor Documentation

decaf::security::SecureRandom::SecureRandom ( )

Creates a new instance of a secure random number generator that implements the default random number algorithm.

The SecureRandom instance that is created with this constructor is unseeded and can be seeded by calling the setSeed method. Calls to nextBytes on an unseeded SecureRandom result in the object seeding itself.

decaf::security::SecureRandom::SecureRandom ( const std::vector< unsigned char > &  seed)

Creates a new instance of a secure random number generator that implements the default random number algorithm.

The SecureRandom instance created by this constructor is seeded using the passed byte array.

Parameters
seedThe seed bytes to use to seed this secure random number generator.
decaf::security::SecureRandom::SecureRandom ( const unsigned char *  seed,
int  size 
)

Creates a new instance of a secure random number generator that implements the default random number algorithm.

The SecureRandom instance created by this constructor is seeded using the passed byte array.

Parameters
seedThe seed bytes to use to seed this secure random number generator.
sizeThe number of bytes in the seed buffer.
Exceptions
NullPointerExceptionif the seed buffer is NULL.
IllegalArgumentExceptionif the size value is negative.
virtual decaf::security::SecureRandom::~SecureRandom ( )
virtual

Member Function Documentation

virtual int decaf::security::SecureRandom::next ( int  bits)
protectedvirtual

Answers a pseudo-random uniformly distributed int value of the number of bits specified by the argument bits as described by Donald E.Knuth in The Art of Computer Programming, Volume 2: Seminumerical Algorithms, section 3.2.1.

Returns
int a pseudo-random generated int number
Parameters
bitsnumber of bits of the returned value
See Also
nextBytes
nextDouble
nextFloat
nextInt()
nextInt(int)
nextGaussian
nextLong

Reimplemented from decaf::util::Random.

virtual void decaf::security::SecureRandom::nextBytes ( std::vector< unsigned char > &  buf)
virtual

Modifies the byte array by a random sequence of bytes generated by this random number generator.

Parameters
bufnon-null array to contain the new random bytes
See Also
next

Reimplemented from decaf::util::Random.

virtual void decaf::security::SecureRandom::nextBytes ( unsigned char *  buf,
int  size 
)
virtual

Modifies the byte array by a random sequence of bytes generated by this random number generator.

Parameters
bufnon-null array to contain the new random bytes
See Also
next
Exceptions
NullPointerExceptionif buff is NULL
IllegalArgumentExceptionif size is negative

Reimplemented from decaf::util::Random.

virtual void decaf::security::SecureRandom::setSeed ( unsigned long long  seed)
virtual

Modifies the seed using linear congruential formula presented in The Art of Computer Programming, Volume 2, Section 3.2.1.

Parameters
seedthe seed that alters the state of the random number generator
See Also
next
Random()
#Random(long)

Reimplemented from decaf::util::Random.

virtual void decaf::security::SecureRandom::setSeed ( const std::vector< unsigned char > &  seed)
virtual

Supplements or sets the seed of this secure random number generator, calls to this method never reduces randomness.

Parameters
seedA vector of bytes that is used update the seed of the RNG.
virtual void decaf::security::SecureRandom::setSeed ( const unsigned char *  seed,
int  size 
)
virtual

Supplements or sets the seed of this secure random number generator, calls to this method never reduces randomness.

Parameters
seedThe seed bytes to use to seed this secure random number generator.
sizeThe number of bytes in the seed buffer.
Exceptions
NullPointerExceptionif the seed buffer is NULL.
IllegalArgumentExceptionif the size value is negative.

The documentation for this class was generated from the following file: