sprng.c 1.5 KB

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