Ability to provide alternate timing implementation

This commit is contained in:
Paul Bakker 2014-02-06 15:11:55 +01:00
parent 64abd83b67
commit f2561b3f69
4 changed files with 27 additions and 3 deletions

View File

@ -10,6 +10,7 @@ Features
* Support for RSASSA-PSS keys and signatures in certificates, CSRs * Support for RSASSA-PSS keys and signatures in certificates, CSRs
and CRLs and CRLs
* Single Platform compatilibity layer (for memory / printf / fprintf) * Single Platform compatilibity layer (for memory / printf / fprintf)
* Ability to provide alternate timing implementation
Changes Changes
* Deprecated the Memory layer * Deprecated the Memory layer

View File

@ -159,6 +159,19 @@
* \{ * \{
*/ */
/**
* \def POLARSSL_TIMING_ALT
*
* Uncomment to provide your own alternate implementation for hardclock(),
* get_timer(), set_alarm() and m_sleep().
*
* Only works if you have POLARSSL_TIMING_C enabled.
*
* You will need to provide a header "timing_alt.h" and an implementation at
* compile time.
*/
//#define POLARSSL_TIMING_ALT
/** /**
* \def POLARSSL_XXX_ALT * \def POLARSSL_XXX_ALT
* *

View File

@ -3,7 +3,7 @@
* *
* \brief Portable interface to the CPU cycle counter * \brief Portable interface to the CPU cycle counter
* *
* Copyright (C) 2006-2013, Brainspark B.V. * Copyright (C) 2006-2014, Brainspark B.V.
* *
* This file is part of PolarSSL (http://www.polarssl.org) * This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@ -27,6 +27,12 @@
#ifndef POLARSSL_TIMING_H #ifndef POLARSSL_TIMING_H
#define POLARSSL_TIMING_H #define POLARSSL_TIMING_H
#include "config.h"
#if !defined(POLARSSL_TIMING_ALT)
// Regular implementation
//
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -72,4 +78,8 @@ void m_sleep( int milliseconds );
} }
#endif #endif
#else /* POLARSSL_TIMING_ALT */
#include "timing_alt.h"
#endif /* POLARSSL_TIMING_ALT */
#endif /* timing.h */ #endif /* timing.h */

View File

@ -1,7 +1,7 @@
/* /*
* Portable interface to the CPU cycle counter * Portable interface to the CPU cycle counter
* *
* Copyright (C) 2006-2010, Brainspark B.V. * Copyright (C) 2006-2014, Brainspark B.V.
* *
* This file is part of PolarSSL (http://www.polarssl.org) * This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@ -25,7 +25,7 @@
#include "polarssl/config.h" #include "polarssl/config.h"
#if defined(POLARSSL_TIMING_C) #if defined(POLARSSL_TIMING_C) && !defined(POLARSSL_TIMING_ALT)
#include "polarssl/timing.h" #include "polarssl/timing.h"