kernel/eka/euser/us_exec.cpp
branchRCL_3
changeset 19 4a8fed1c0ef6
parent 0 a41df078684a
child 43 c1f20ce4abcf
equal deleted inserted replaced
15:2d65c2f76d7b 19:4a8fed1c0ef6
  6356 	Exec::DebugPrint((TAny*)&aDes8, 1);
  6356 	Exec::DebugPrint((TAny*)&aDes8, 1);
  6357 	}
  6357 	}
  6358 
  6358 
  6359 EXPORT_C TUint32 Math::Random()
  6359 EXPORT_C TUint32 Math::Random()
  6360 /**
  6360 /**
  6361 Gets 32 random bits from the kernel's random pool.
  6361 Gets 32 random bits from the kernel's random number generator.
       
  6362 
       
  6363 The returned random data may or may not be cryptographically secure but should be of a high quality for
       
  6364 non-cryptographic purposes.
       
  6365 
       
  6366 This function uses a cryptographically strong random number generator to generate the random data, which can
       
  6367 be slower than insecure generators. If security is not important, a faster generator may be used such as
       
  6368 Math::Rand().
  6362 
  6369 
  6363 @return The 32 random bits.
  6370 @return The 32 random bits.
  6364 */
  6371 */
  6365 	{
  6372 	{
  6366 
  6373 
  6367 	return Exec::MathRandom();
  6374 	return Exec::MathRandom();
  6368 	}
  6375 	}
  6369 
  6376 
       
  6377 EXPORT_C void Math::Random(TDes8& aRandomValue)
       
  6378 /**
       
  6379 Fills the provided descriptor with random data up to its current length. The number of random bytes required
       
  6380 should be specified by setting the length of the descriptor that is passed to this function.
       
  6381 
       
  6382 The returned random data may or may not be cryptographically secure but should be of a high quality for
       
  6383 non-cryptographic purposes.
       
  6384 
       
  6385 This function uses a cryptographically strong random number generator to generate the random data, which can
       
  6386 be slower than insecure generators. If security is not important, a faster generator may be used such as
       
  6387 Math::Rand().
       
  6388 
       
  6389 @param aRandomValue on return, the descriptor is filled with the requested number of random bytes.
       
  6390 */
       
  6391 	{
       
  6392 	Exec::MathSecureRandom(aRandomValue);
       
  6393     }
       
  6394 
       
  6395 
       
  6396 EXPORT_C void Math::RandomL(TDes8& aRandomValue)
       
  6397 /**
       
  6398 Fills the provided descriptor with random data up to its current length. The number of random bytes required
       
  6399 should be specified by setting the length of the descriptor that is passed to the function.
       
  6400 
       
  6401 If the returned random data cannot be guaranteed to be cryptographically secure, the function will leave with
       
  6402 KErrNotReady to indicate that the returned data should not be used for cryptographic purposes.
       
  6403 
       
  6404 The security strength of the cryptographically strong random number generator is 256 bits.
       
  6405 
       
  6406 @param aRandomValue  on return, the descriptor is filled with the requested number of random bytes.
       
  6407 
       
  6408 @leave KErrNotReady  if the returned random data cannot be guaranteed to be cryptographically secure.
       
  6409 */
       
  6410 	{
       
  6411 	User::LeaveIfError(Exec::MathSecureRandom(aRandomValue));
       
  6412 	}
       
  6413 
       
  6414 EXPORT_C TUint32 Math::RandomL()
       
  6415 /**
       
  6416 Gets 32 random bits from the kernel's random number generator.
       
  6417 
       
  6418 If the returned random data could not be guaranteed to be cryptographically secure, the function will instead
       
  6419 leave with KErrNotReady to indicate that data was not available.
       
  6420 
       
  6421 The security strength of the cryptographically strong random number generator is 256 bits.
       
  6422 
       
  6423 @leave KErrNotReady  if no data was returned as it could not be guaranteed to be cryptographically secure.
       
  6424 
       
  6425 @return The 32 random bits.
       
  6426 */
       
  6427 	{
       
  6428 	TBuf8<sizeof(TUint32)> randomBuffer;
       
  6429 	randomBuffer.SetMax();
       
  6430 	User::LeaveIfError(Exec::MathSecureRandom(randomBuffer));
       
  6431 	return *(TUint32*)(randomBuffer.Ptr());
       
  6432 	}
  6370 
  6433 
  6371 
  6434 
  6372 EXPORT_C void User::IMB_Range(TAny* aStart, TAny* aEnd)
  6435 EXPORT_C void User::IMB_Range(TAny* aStart, TAny* aEnd)
  6373 /**
  6436 /**
  6374 Does the necessary preparations to guarantee correct execution of code in the 
  6437 Does the necessary preparations to guarantee correct execution of code in the