1 #ifndef _IPXE_RTC_ENTROPY_H
2 #define _IPXE_RTC_ENTROPY_H
6 * RTC-based entropy source
10 FILE_LICENCE ( GPL2_OR_LATER );
15 #define ENTROPY_PREFIX_rtc
17 #define ENTROPY_PREFIX_rtc __rtc_
21 * min-entropy per sample
23 * @ret min_entropy min-entropy of each sample
25 static inline __always_inline double
26 ENTROPY_INLINE ( rtc, min_entropy_per_sample ) ( void ) {
28 /* The min-entropy has been measured on several platforms
29 * using the entropy_sample test code. Modelling the samples
30 * as independent, and using a confidence level of 99.99%, the
31 * measurements were as follows:
33 * qemu-kvm : 7.38 bits
35 * Physical hardware : 2.67 bits
37 * We choose the lowest of these (2.67 bits) and apply a 50%
38 * safety margin to allow for some potential non-independence
44 extern uint8_t rtc_sample ( void );
49 * @ret noise Noise sample
50 * @ret rc Return status code
52 static inline __always_inline int
53 ENTROPY_INLINE ( rtc, get_noise ) ( noise_sample_t *noise ) {
56 *noise = rtc_sample();
58 /* Always successful */
62 #endif /* _IPXE_RTC_ENTROPY_H */