sprng.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. &sprng_done,
  25. &sprng_export,
  26. &sprng_import
  27. };
  28. int sprng_start(prng_state *prng)
  29. {
  30. return CRYPT_OK;
  31. }
  32. int sprng_add_entropy(const unsigned char *buf, unsigned long len, prng_state *prng)
  33. {
  34. return CRYPT_OK;
  35. }
  36. int sprng_ready(prng_state *prng)
  37. {
  38. return CRYPT_OK;
  39. }
  40. unsigned long sprng_read(unsigned char *buf, unsigned long len, prng_state *prng)
  41. {
  42. _ARGCHK(buf != NULL);
  43. return rng_get_bytes(buf, len, NULL);
  44. }
  45. void sprng_done(prng_state *prng)
  46. {
  47. _ARGCHK(prng != NULL);
  48. }
  49. int sprng_export(unsigned char *out, unsigned long *outlen, prng_state *prng)
  50. {
  51. _ARGCHK(outlen != NULL);
  52. *outlen = 0;
  53. return CRYPT_OK;
  54. }
  55. int sprng_import(const unsigned char *in, unsigned long inlen, prng_state *prng)
  56. {
  57. return CRYPT_OK;
  58. }
  59. #endif