You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

null_entropy.h 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef _IPXE_NULL_ENTROPY_H
  2. #define _IPXE_NULL_ENTROPY_H
  3. /** @file
  4. *
  5. * Nonexistent entropy source
  6. *
  7. * This source provides no entropy and must NOT be used in a
  8. * security-sensitive environment.
  9. */
  10. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  11. #include <stdint.h>
  12. #ifdef ENTROPY_NULL
  13. #define ENTROPY_PREFIX_null
  14. #else
  15. #define ENTROPY_PREFIX_null __null_
  16. #endif
  17. static inline __always_inline int
  18. ENTROPY_INLINE ( null, entropy_enable ) ( void ) {
  19. /* Do nothing */
  20. return 0;
  21. }
  22. static inline __always_inline void
  23. ENTROPY_INLINE ( null, entropy_disable ) ( void ) {
  24. /* Do nothing */
  25. }
  26. static inline __always_inline min_entropy_t
  27. ENTROPY_INLINE ( null, min_entropy_per_sample ) ( void ) {
  28. /* Actual amount of min-entropy is zero. To avoid
  29. * division-by-zero errors and to allow compilation of
  30. * entropy-consuming code, pretend to have 1 bit of entropy in
  31. * each sample.
  32. */
  33. return MIN_ENTROPY ( 1.0 );
  34. }
  35. static inline __always_inline int
  36. ENTROPY_INLINE ( null, get_noise ) ( noise_sample_t *noise ) {
  37. /* All sample values are constant */
  38. *noise = 0x01;
  39. return 0;
  40. }
  41. #endif /* _IPXE_NULL_ENTROPY_H */