公共
- 获取随机数函数
void get_random_bytes(void *buf, int nbytes);这个函数向外开发了内核的接口,将好的随机数放到buf中,这些随机数可以很好的用于生成键值以及TCP的顺序号。这个函数不依赖于硬件随机数生成源。如果想直接用硬件提供的随机源,请用use get_random_bytes_arch()
/*
* This function is the exported kernel interface. It returns some
* number of good random numbers, suitable for key generation, seeding
* TCP sequence numbers, etc. It does not rely on the hardware random
* number generator. For random bytes direct from the hardware RNG
* (when available), use get_random_bytes_arch().
*/
例子:
include/linux/random.