ch2-01.c 691 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Name : ch2-01.c
  3. * Purpose : Demonstration of reading the RNG
  4. * Author : Tom St Denis
  5. *
  6. * History : v0.81 Initial release
  7. */
  8. /* ch2-02-2 */
  9. #include <mycrypt.h>
  10. int main(void)
  11. {
  12. unsigned char buf[16];
  13. unsigned long len;
  14. int ix;
  15. /* read the RNG */
  16. len = rng_get_bytes(buf, sizeof(buf), NULL);
  17. /* verify return */
  18. if (len != sizeof(buf)) {
  19. printf("Error: Only read %lu bytes.\n", len);
  20. } else {
  21. printf("Read %lu bytes\n", len);
  22. for (ix = 0; ix < sizeof(buf); ix++) {
  23. printf("%02x ", buf[ix]);
  24. }
  25. printf("\n");
  26. }
  27. return EXIT_SUCCESS;
  28. }
  29. /* ch2-02-2 */