random_pool:add a new api arc4random
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
parent
352006af6d
commit
0c26658906
@ -550,3 +550,27 @@ void arc4random_buf(FAR void *bytes, size_t nbytes)
|
||||
rng_buf_internal(bytes, nbytes);
|
||||
nxmutex_unlock(&g_rng.rd_lock);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arc4random
|
||||
*
|
||||
* Description:
|
||||
* Returns a single 32-bit value. This is the preferred interface for
|
||||
* getting random numbers. The traditional /dev/random approach is
|
||||
* susceptible for things like the attacker exhausting file
|
||||
* descriptors on purpose.
|
||||
*
|
||||
* Note that this function cannot fail, other than by asserting.
|
||||
*
|
||||
* Returned Value:
|
||||
* a random 32-bit value.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
uint32_t arc4random(void)
|
||||
{
|
||||
uint32_t ret;
|
||||
|
||||
arc4random_buf(&ret, sizeof(ret));
|
||||
return ret;
|
||||
}
|
||||
|
@ -138,6 +138,7 @@ long random(void);
|
||||
|
||||
#ifdef CONFIG_CRYPTO_RANDOM_POOL
|
||||
void arc4random_buf(FAR void *bytes, size_t nbytes);
|
||||
uint32_t arc4random(void);
|
||||
#endif
|
||||
|
||||
/* Environment variable support */
|
||||
|
Loading…
Reference in New Issue
Block a user