mirror of
https://github.com/ipxe/ipxe
synced 2025-12-21 20:40:25 +03:00
[rng] Add Linux entropy source using /dev/random
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -54,6 +54,7 @@ typedef uint8_t entropy_sample_t;
|
||||
|
||||
/* Include all architecture-independent entropy API headers */
|
||||
#include <ipxe/null_entropy.h>
|
||||
#include <ipxe/linux/linux_entropy.h>
|
||||
|
||||
/* Include all architecture-dependent entropy API headers */
|
||||
#include <bits/entropy.h>
|
||||
|
||||
@@ -247,6 +247,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||
#define ERRFILE_drbg ( ERRFILE_OTHER | 0x00250000 )
|
||||
#define ERRFILE_entropy ( ERRFILE_OTHER | 0x00260000 )
|
||||
#define ERRFILE_rsa ( ERRFILE_OTHER | 0x00270000 )
|
||||
#define ERRFILE_linux_entropy ( ERRFILE_OTHER | 0x00280000 )
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
32
src/include/ipxe/linux/linux_entropy.h
Normal file
32
src/include/ipxe/linux/linux_entropy.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef _IPXE_LINUX_ENTROPY_H
|
||||
#define _IPXE_LINUX_ENTROPY_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* iPXE entropy API for linux
|
||||
*
|
||||
*/
|
||||
|
||||
FILE_LICENCE(GPL2_OR_LATER);
|
||||
|
||||
#ifdef ENTROPY_LINUX
|
||||
#define ENTROPY_PREFIX_linux
|
||||
#else
|
||||
#define ENTROPY_PREFIX_linux __linux_
|
||||
#endif
|
||||
|
||||
/**
|
||||
* min-entropy per sample
|
||||
*
|
||||
* @ret min_entropy min-entropy of each sample
|
||||
*/
|
||||
static inline __always_inline double
|
||||
ENTROPY_INLINE ( linux, min_entropy_per_sample ) ( void ) {
|
||||
|
||||
/* We read single bytes from /dev/random and assume that each
|
||||
* contains full entropy.
|
||||
*/
|
||||
return 8;
|
||||
}
|
||||
|
||||
#endif /* _IPXE_LINUX_ENTROPY_H */
|
||||
Reference in New Issue
Block a user