entropy.h 858 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef ENTROPY_H_
  2. #define ENTROPY_H_
  3. #include <stddef.h>
  4. #include <stdint.h>
  5. /* Opaque type. */
  6. struct entropy_read_cookie;
  7. /**
  8. * entropy_read_init(void):
  9. * Initialize the ability to produce random bytes from the operating system,
  10. * and return a cookie.
  11. */
  12. struct entropy_read_cookie * entropy_read_init(void);
  13. /**
  14. * entropy_read_fill(er, buf, buflen):
  15. * Fill the given buffer with random bytes provided by the operating system
  16. * using the resources in ${er}.
  17. */
  18. int entropy_read_fill(struct entropy_read_cookie *, uint8_t *, size_t);
  19. /**
  20. * entropy_read_done(er):
  21. * Release any resources used by ${er}.
  22. */
  23. int entropy_read_done(struct entropy_read_cookie * er);
  24. /**
  25. * entropy_read(buf, buflen):
  26. * Fill the given buffer with random bytes provided by the operating system.
  27. */
  28. int entropy_read(uint8_t *, size_t);
  29. #endif /* !ENTROPY_H_ */