[rng] Add Linux entropy source using /dev/random

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2012-03-18 17:03:58 +00:00
parent 196f0bb081
commit 5af9e62196
5 changed files with 131 additions and 1 deletions

View File

@@ -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>

View File

@@ -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 )
/** @} */

View 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 */