entropium.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* entropium.h */
  2. /*
  3. This file is part of the ARM-Crypto-Lib.
  4. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. /**
  17. * File: entropium.h
  18. * Author: Daniel Otte
  19. * Date: 23.07.2006
  20. * License: GPL
  21. * Description: This file contains the declarations for the pseudo-random-number generator.
  22. **/
  23. /**
  24. * \file entropium.h
  25. * \author Daniel Otte
  26. * \date 23.07.2006
  27. * \license GPLv3 or later
  28. * \brief This file contains the declarations for the pseudo-random-number generator.
  29. **/
  30. #ifndef ENTROPIUM_H_
  31. #define ENTROPIUM_H_
  32. #include <stdint.h>
  33. /*
  34. * length in bits
  35. */
  36. #define ENTROPIUM_RANDOMBLOCK_SIZE 32 /* bytes */
  37. /** \fn void entropium_addEntropy(unsigned length_b, const void* data)
  38. * \brief add entropy to the prng
  39. *
  40. * This function adds data to the internal entropy pool
  41. * \param length_b length of the data block in bits
  42. * \param data pointer to the data
  43. */
  44. void entropium_addEntropy(unsigned length_b, const void* data);
  45. /** \fn void entropium_getRandomBlock(void* b)
  46. * \brief generate a fixed size block of random data
  47. *
  48. * This function writes 32 bytes of random extracted from the entropy pool
  49. * in the supplied buffer.
  50. * \param b buffer where the random data gets written
  51. */
  52. void entropium_getRandomBlock(void* b);
  53. /** \fn uint8_t entropium_getRandomByte(void)
  54. * \brief get a single byte of random data
  55. *
  56. * This function utilizes a internal buffer which gets automatically filled
  57. * again.
  58. * \return a byte of random data
  59. */
  60. uint8_t entropium_getRandomByte(void);
  61. /** \fn void entropium_fillBlockRandom(void* block, unsigned length_B)
  62. * \brief get a block of random data
  63. *
  64. * This function writes random data extracted from the entropy pool in the
  65. * supplied buffer. It shares a internal buffer with the
  66. * entropium_getRandomByte() function.
  67. * \param block pointer to the buffer where the random data goes
  68. * \param length_B number of bytes to be written to the buffer
  69. */
  70. void entropium_fillBlockRandom(void* block, unsigned length_B);
  71. #endif /*PRNG_H_*/