havege.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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: Apache-2.0
  8. *
  9. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  10. * not use this file except in compliance with the License.
  11. * You may obtain a copy of the License at
  12. *
  13. * http://www.apache.org/licenses/LICENSE-2.0
  14. *
  15. * Unless required by applicable law or agreed to in writing, software
  16. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  17. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. * See the License for the specific language governing permissions and
  19. * limitations under the License.
  20. *
  21. * This file is part of mbed TLS (https://tls.mbed.org)
  22. */
  23. #ifndef MBEDTLS_HAVEGE_H
  24. #define MBEDTLS_HAVEGE_H
  25. #include <stddef.h>
  26. #define MBEDTLS_HAVEGE_COLLECT_SIZE 1024
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /**
  31. * \brief HAVEGE state structure
  32. */
  33. typedef struct
  34. {
  35. int PT1, PT2, offset[2];
  36. int pool[MBEDTLS_HAVEGE_COLLECT_SIZE];
  37. int WALK[8192];
  38. }
  39. mbedtls_havege_state;
  40. /**
  41. * \brief HAVEGE initialization
  42. *
  43. * \param hs HAVEGE state to be initialized
  44. */
  45. void mbedtls_havege_init( mbedtls_havege_state *hs );
  46. /**
  47. * \brief Clear HAVEGE state
  48. *
  49. * \param hs HAVEGE state to be cleared
  50. */
  51. void mbedtls_havege_free( mbedtls_havege_state *hs );
  52. /**
  53. * \brief HAVEGE rand function
  54. *
  55. * \param p_rng A HAVEGE state
  56. * \param output Buffer to fill
  57. * \param len Length of buffer
  58. *
  59. * \return 0
  60. */
  61. int mbedtls_havege_random( void *p_rng, unsigned char *output, size_t len );
  62. #ifdef __cplusplus
  63. }
  64. #endif
  65. #endif /* havege.h */