2
0

sprng.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* LibTomCrypt, modular cryptographic library -- Tom St Denis
  2. *
  3. * LibTomCrypt is a library that provides various cryptographic
  4. * algorithms in a highly modular and flexible manner.
  5. *
  6. * The library is free for all purposes without any express
  7. * guarantee it works.
  8. *
  9. * Tom St Denis, [email protected], http://libtomcrypt.org
  10. */
  11. /* A secure PRNG using the RNG functions. Basically this is a
  12. * wrapper that allows you to use a secure RNG as a PRNG
  13. * in the various other functions.
  14. */
  15. #include "mycrypt.h"
  16. #ifdef SPRNG
  17. const struct _prng_descriptor sprng_desc =
  18. {
  19. "sprng",
  20. &sprng_start,
  21. &sprng_add_entropy,
  22. &sprng_ready,
  23. &sprng_read
  24. };
  25. int sprng_start(prng_state *prng)
  26. {
  27. return CRYPT_OK;
  28. }
  29. int sprng_add_entropy(const unsigned char *buf, unsigned long len, prng_state *prng)
  30. {
  31. return CRYPT_OK;
  32. }
  33. int sprng_ready(prng_state *prng)
  34. {
  35. return CRYPT_OK;
  36. }
  37. unsigned long sprng_read(unsigned char *buf, unsigned long len, prng_state *prng)
  38. {
  39. _ARGCHK(buf != NULL);
  40. return rng_get_bytes(buf, len, NULL);
  41. }
  42. #endif