--- a/kernel/eka/euser/us_exec.cpp Tue Feb 02 01:24:03 2010 +0200
+++ b/kernel/eka/euser/us_exec.cpp Sat Feb 20 00:10:51 2010 +0200
@@ -6358,7 +6358,14 @@
EXPORT_C TUint32 Math::Random()
/**
-Gets 32 random bits from the kernel's random pool.
+Gets 32 random bits from the kernel's random number generator.
+
+The returned random data may or may not be cryptographically secure but should be of a high quality for
+non-cryptographic purposes.
+
+This function uses a cryptographically strong random number generator to generate the random data, which can
+be slower than insecure generators. If security is not important, a faster generator may be used such as
+Math::Rand().
@return The 32 random bits.
*/
@@ -6367,6 +6374,62 @@
return Exec::MathRandom();
}
+EXPORT_C void Math::Random(TDes8& aRandomValue)
+/**
+Fills the provided descriptor with random data up to its current length. The number of random bytes required
+should be specified by setting the length of the descriptor that is passed to this function.
+
+The returned random data may or may not be cryptographically secure but should be of a high quality for
+non-cryptographic purposes.
+
+This function uses a cryptographically strong random number generator to generate the random data, which can
+be slower than insecure generators. If security is not important, a faster generator may be used such as
+Math::Rand().
+
+@param aRandomValue on return, the descriptor is filled with the requested number of random bytes.
+*/
+ {
+ Exec::MathSecureRandom(aRandomValue);
+ }
+
+
+EXPORT_C void Math::RandomL(TDes8& aRandomValue)
+/**
+Fills the provided descriptor with random data up to its current length. The number of random bytes required
+should be specified by setting the length of the descriptor that is passed to the function.
+
+If the returned random data cannot be guaranteed to be cryptographically secure, the function will leave with
+KErrNotReady to indicate that the returned data should not be used for cryptographic purposes.
+
+The security strength of the cryptographically strong random number generator is 256 bits.
+
+@param aRandomValue on return, the descriptor is filled with the requested number of random bytes.
+
+@leave KErrNotReady if the returned random data cannot be guaranteed to be cryptographically secure.
+*/
+ {
+ User::LeaveIfError(Exec::MathSecureRandom(aRandomValue));
+ }
+
+EXPORT_C TUint32 Math::RandomL()
+/**
+Gets 32 random bits from the kernel's random number generator.
+
+If the returned random data could not be guaranteed to be cryptographically secure, the function will instead
+leave with KErrNotReady to indicate that data was not available.
+
+The security strength of the cryptographically strong random number generator is 256 bits.
+
+@leave KErrNotReady if no data was returned as it could not be guaranteed to be cryptographically secure.
+
+@return The 32 random bits.
+*/
+ {
+ TBuf8<sizeof(TUint32)> randomBuffer;
+ randomBuffer.SetMax();
+ User::LeaveIfError(Exec::MathSecureRandom(randomBuffer));
+ return *(TUint32*)(randomBuffer.Ptr());
+ }
EXPORT_C void User::IMB_Range(TAny* aStart, TAny* aEnd)