iPXE
null_entropy.h
Go to the documentation of this file.
00001 #ifndef _IPXE_NULL_ENTROPY_H
00002 #define _IPXE_NULL_ENTROPY_H
00003 
00004 /** @file
00005  *
00006  * Nonexistent entropy source
00007  *
00008  * This source provides no entropy and must NOT be used in a
00009  * security-sensitive environment.
00010  */
00011 
00012 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00013 
00014 #include <stdint.h>
00015 
00016 #ifdef ENTROPY_NULL
00017 #define ENTROPY_PREFIX_null
00018 #else
00019 #define ENTROPY_PREFIX_null __null_
00020 #endif
00021 
00022 static inline __always_inline int
00023 ENTROPY_INLINE ( null, entropy_enable ) ( void ) {
00024         /* Do nothing */
00025         return 0;
00026 }
00027 
00028 static inline __always_inline void
00029 ENTROPY_INLINE ( null, entropy_disable ) ( void ) {
00030         /* Do nothing */
00031 }
00032 
00033 static inline __always_inline min_entropy_t
00034 ENTROPY_INLINE ( null, min_entropy_per_sample ) ( void ) {
00035         /* Actual amount of min-entropy is zero.  To avoid
00036          * division-by-zero errors and to allow compilation of
00037          * entropy-consuming code, pretend to have 1 bit of entropy in
00038          * each sample.
00039          */
00040         return MIN_ENTROPY ( 1.0 );
00041 }
00042 
00043 static inline __always_inline int
00044 ENTROPY_INLINE ( null, get_noise ) ( noise_sample_t *noise ) {
00045 
00046         /* All sample values are constant */
00047         *noise = 0x01;
00048 
00049         return 0;
00050 }
00051 
00052 #endif /* _IPXE_NULL_ENTROPY_H */