Disable timing.c

Move hardclock implementation to entropy_pool.c to use that as a
(pseudo) entropy source for now
This commit is contained in:
Manuel Pégourié-Gonnard 2015-05-22 11:58:37 +02:00
parent a8b2673bce
commit 524d507363
5 changed files with 27 additions and 6 deletions

View file

@ -2150,7 +2150,7 @@
* *
* This module is used by the HAVEGE random number generator. * This module is used by the HAVEGE random number generator.
*/ */
#define MBEDTLS_TIMING_C //#define MBEDTLS_TIMING_C
/** /**
* \def MBEDTLS_VERSION_C * \def MBEDTLS_VERSION_C

View file

@ -47,7 +47,7 @@ int mbedtls_havege_poll( void *data,
unsigned char *output, size_t len, size_t *olen ); unsigned char *output, size_t len, size_t *olen );
#endif #endif
#if defined(MBEDTLS_TIMING_C) #if defined(MBEDTLS_TIMING_C) || defined(TARGET_LIKE_CORTEX_M4)
/** /**
* \brief mbedtls_timing_hardclock-based entropy poll callback * \brief mbedtls_timing_hardclock-based entropy poll callback
*/ */

View file

@ -65,7 +65,7 @@ void mbedtls_entropy_init( mbedtls_entropy_context *ctx )
mbedtls_entropy_add_source( ctx, mbedtls_platform_entropy_poll, NULL, mbedtls_entropy_add_source( ctx, mbedtls_platform_entropy_poll, NULL,
MBEDTLS_ENTROPY_MIN_PLATFORM ); MBEDTLS_ENTROPY_MIN_PLATFORM );
#endif #endif
#if defined(MBEDTLS_TIMING_C) #if defined(MBEDTLS_TIMING_C) || defined(TARGET_LIKE_CORTEX_M4)
mbedtls_entropy_add_source( ctx, mbedtls_hardclock_poll, NULL, MBEDTLS_ENTROPY_MIN_HARDCLOCK ); mbedtls_entropy_add_source( ctx, mbedtls_hardclock_poll, NULL, MBEDTLS_ENTROPY_MIN_HARDCLOCK );
#endif #endif
#if defined(MBEDTLS_HAVEGE_C) #if defined(MBEDTLS_HAVEGE_C)

View file

@ -17,8 +17,10 @@
#include "mbedtls/entropy.h" #include "mbedtls/entropy.h"
#include "mbedtls/entropy_poll.h" #include "mbedtls/entropy_poll.h"
#if defined(MBEDTLS_TIMING_C) #if defined(MBEDTLS_TIMING_C) || defined(TARGET_LIKE_CORTEX_M4)
#include <string.h> #include <string.h>
#endif
#if defined(MBEDTLS_TIMING_C)
#include "mbedtls/timing.h" #include "mbedtls/timing.h"
#endif #endif
#if defined(MBEDTLS_HAVEGE_C) #if defined(MBEDTLS_HAVEGE_C)
@ -159,7 +161,26 @@ int mbedtls_platform_entropy_poll( void *data,
#endif /* _WIN32 && !EFIX64 && !EFI32 */ #endif /* _WIN32 && !EFIX64 && !EFI32 */
#endif /* !MBEDTLS_NO_PLATFORM_ENTROPY */ #endif /* !MBEDTLS_NO_PLATFORM_ENTROPY */
#if defined(MBEDTLS_TIMING_C) #if defined(TARGET_LIKE_CORTEX_M4)
#include "MK64F12.h"
#include "core_cm4.h"
static unsigned long mbedtls_timing_hardclock( void )
{
static int dwt_started = 0;
if( dwt_started == 0 )
{
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
}
return( DWT->CYCCNT );
}
#endif
#if defined(MBEDTLS_TIMING_C) || defined(TARGET_LIKE_CORTEX_M4)
int mbedtls_hardclock_poll( void *data, int mbedtls_hardclock_poll( void *data,
unsigned char *output, size_t len, size_t *olen ) unsigned char *output, size_t len, size_t *olen )
{ {

View file

@ -1,6 +1,6 @@
{ {
"name": "mbedtls", "name": "mbedtls",
"version": "2.0.0-beta9", "version": "2.0.0-beta9a",
"private": true, "private": true,
"license": "mbed partner license", "license": "mbed partner license",
"extraIncludes": ["include"], "extraIncludes": ["include"],