TRandom Class Reference

#include <random.h>

Link against: random.lib

class TRandom
Public Member Functions
IMPORT_C voidRandom(TDes8 &)
IMPORT_C voidRandomL(TDes8 &)
IMPORT_C voidSecureRandomL(TDes8 &)

Detailed Description

The user interface to the random number generator.

Member Function Documentation

Random ( TDes8 & )

IMPORT_C voidRandom(TDes8 &aDestination)[static]

Fills the provided buffer with pseudo-random data up to its current length, discarding any current content.

This method will not return secure random numbers for some time after the phone boot-up. Because, pseudo-random number generator will take some time to attain a secure state by collecting enough entropy samples after the boot-up. Till that time, the pseudo-random numbers generated may not be cryptographically secure and there is no way to get to know about it with this API. So, if explcit notification on the strength of the random numbers is necessary, use TRandom::SecureRandomL.

DeprecatedUse RandomL() instead
Parameters
aDestinationThe buffer in which to write the random data.
Panic Codes
Thisfunction can panic under low memory conditions

RandomL ( TDes8 & )

IMPORT_C voidRandomL(TDes8 &aDestination)[static]

Fills the provided buffer with pseudo-random data up to its current length, discarding any current content.

This method will not return secure random numbers for some time after the phone boot-up. Because, pseudo-random number generator will take some time to attain a secure state by collecting enough entropy samples after the boot-up. Till that time, the pseudo-random numbers generated may not be cryptographically secure and there is no way to get to know about it with this API. So, if explcit notification on the strength of the random numbers is necessary, use TRandom::SecureRandomL.

Parameters
aDestinationThe buffer in which to write the random data.
Leave Codes
Thisfunction can leave under low memory conditions

SecureRandomL ( TDes8 & )

IMPORT_C voidSecureRandomL(TDes8 &aDestination)[static]

Fills the provided buffer with the pseudo-random data up to its current length, discarding any current content of the descriptor. When this method returns normally (with out leave), the system state is secure and hence the random numbers generated are cryptographically secure as well. When this method leaves with the error code KErrNotSecure, the system internal state is not secure and hence the random numbers too.

Though this method leaves when the system internal state is not secure, still the descriptor will be filled with pseudo-random bytes. This random data may or may not be secure enough. Recommended to treat these numbers as not secure.

Parameters
aDestinationThe buffer in which to write the random data.
Leave Codes
KErrNotSecureThe generated random numbers is not secure enough for cryptographic operations. Otherwise, leaves with some other system wide error codes.