Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /**
  2.  * \file entropy_poll.h
  3.  *
  4.  * \brief Platform-specific and custom entropy polling functions
  5.  */
  6. /*
  7.  *  Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
  8.  *  SPDX-License-Identifier: GPL-2.0
  9.  *
  10.  *  This program is free software; you can redistribute it and/or modify
  11.  *  it under the terms of the GNU General Public License as published by
  12.  *  the Free Software Foundation; either version 2 of the License, or
  13.  *  (at your option) any later version.
  14.  *
  15.  *  This program is distributed in the hope that it will be useful,
  16.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  *  GNU General Public License for more details.
  19.  *
  20.  *  You should have received a copy of the GNU General Public License along
  21.  *  with this program; if not, write to the Free Software Foundation, Inc.,
  22.  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  23.  *
  24.  *  This file is part of mbed TLS (https://tls.mbed.org)
  25.  */
  26. #ifndef MBEDTLS_ENTROPY_POLL_H
  27. #define MBEDTLS_ENTROPY_POLL_H
  28.  
  29. #if !defined(MBEDTLS_CONFIG_FILE)
  30. #include "config.h"
  31. #else
  32. #include MBEDTLS_CONFIG_FILE
  33. #endif
  34.  
  35. #include <stddef.h>
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. /*
  42.  * Default thresholds for built-in sources, in bytes
  43.  */
  44. #define MBEDTLS_ENTROPY_MIN_PLATFORM     32     /**< Minimum for platform source    */
  45. #define MBEDTLS_ENTROPY_MIN_HAVEGE       32     /**< Minimum for HAVEGE             */
  46. #define MBEDTLS_ENTROPY_MIN_HARDCLOCK     4     /**< Minimum for mbedtls_timing_hardclock()        */
  47. #if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE)
  48. #define MBEDTLS_ENTROPY_MIN_HARDWARE     32     /**< Minimum for the hardware source */
  49. #endif
  50.  
  51. /* entropy sources polls for KolibriOS */
  52. int mbedtls_sysfn_3_poll( void *data, unsigned char *output, size_t len, size_t *olen );
  53. int mbedtls_sysfn_26_9_poll( void *data, unsigned char *output, size_t len, size_t *olen );
  54. int mbedtls_sysfn_14_poll( void *data, unsigned char *output, size_t len, size_t *olen );
  55. int mbedtls_sysfn_18_4_poll( void *data, unsigned char *output, size_t len, size_t *olen );
  56. int mbedtls_sysfn_37_0_poll( void *data, unsigned char *output, size_t len, size_t *olen );
  57. int mbedtls_sysfn_66_3_poll( void *data, unsigned char *output, size_t len, size_t *olen );
  58. int mbedtls_sysfn_68_0_poll( void *data, unsigned char *output, size_t len, size_t *olen );
  59.  
  60.  
  61. /**
  62.  * \brief           Entropy poll callback that provides 0 entropy.
  63.  */
  64. #if defined(MBEDTLS_TEST_NULL_ENTROPY)
  65.     int mbedtls_null_entropy_poll( void *data,
  66.                                 unsigned char *output, size_t len, size_t *olen );
  67. #endif
  68.  
  69. #if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
  70. /**
  71.  * \brief           Platform-specific entropy poll callback
  72.  */
  73. int mbedtls_platform_entropy_poll( void *data,
  74.                            unsigned char *output, size_t len, size_t *olen );
  75. #endif
  76.  
  77. #if defined(MBEDTLS_HAVEGE_C)
  78. /**
  79.  * \brief           HAVEGE based entropy poll callback
  80.  *
  81.  * Requires an HAVEGE state as its data pointer.
  82.  */
  83. int mbedtls_havege_poll( void *data,
  84.                  unsigned char *output, size_t len, size_t *olen );
  85. #endif
  86.  
  87. #if defined(MBEDTLS_TIMING_C)
  88. /**
  89.  * \brief           mbedtls_timing_hardclock-based entropy poll callback
  90.  */
  91. int mbedtls_hardclock_poll( void *data,
  92.                     unsigned char *output, size_t len, size_t *olen );
  93. #endif
  94.  
  95. #if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
  96. /**
  97.  * \brief           Entropy poll callback for a hardware source
  98.  *
  99.  * \warning         This is not provided by mbed TLS!
  100.  *                  See \c MBEDTLS_ENTROPY_HARDWARE_ALT in config.h.
  101.  *
  102.  * \note            This must accept NULL as its first argument.
  103.  */
  104. int mbedtls_hardware_poll( void *data,
  105.                            unsigned char *output, size_t len, size_t *olen );
  106. #endif
  107.  
  108. #if defined(MBEDTLS_ENTROPY_NV_SEED)
  109. /**
  110.  * \brief           Entropy poll callback for a non-volatile seed file
  111.  *
  112.  * \note            This must accept NULL as its first argument.
  113.  */
  114. int mbedtls_nv_seed_poll( void *data,
  115.                           unsigned char *output, size_t len, size_t *olen );
  116. #endif
  117.  
  118. #ifdef __cplusplus
  119. }
  120. #endif
  121.  
  122. #endif /* entropy_poll.h */
  123.