havege.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * \file havege.h
  3. *
  4. * \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion
  5. *
  6. * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
  7. * SPDX-License-Identifier: GPL-2.0
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  22. *
  23. * This file is part of mbed TLS (https://tls.mbed.org)
  24. */
  25. #ifndef MBEDTLS_HAVEGE_H
  26. #define MBEDTLS_HAVEGE_H
  27. #include <stddef.h>
  28. #define MBEDTLS_HAVEGE_COLLECT_SIZE 1024
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /**
  33. * \brief HAVEGE state structure
  34. */
  35. typedef struct
  36. {
  37. int PT1, PT2, offset[2];
  38. int pool[MBEDTLS_HAVEGE_COLLECT_SIZE];
  39. int WALK[8192];
  40. }
  41. mbedtls_havege_state;
  42. /**
  43. * \brief HAVEGE initialization
  44. *
  45. * \param hs HAVEGE state to be initialized
  46. */
  47. void mbedtls_havege_init( mbedtls_havege_state *hs );
  48. /**
  49. * \brief Clear HAVEGE state
  50. *
  51. * \param hs HAVEGE state to be cleared
  52. */
  53. void mbedtls_havege_free( mbedtls_havege_state *hs );
  54. /**
  55. * \brief HAVEGE rand function
  56. *
  57. * \param p_rng A HAVEGE state
  58. * \param output Buffer to fill
  59. * \param len Length of buffer
  60. *
  61. * \return 0
  62. */
  63. int mbedtls_havege_random( void *p_rng, unsigned char *output, size_t len );
  64. #ifdef __cplusplus
  65. }
  66. #endif
  67. #endif /* havege.h */