From 810e650c707f9bce7d5eb679f2f5ecc85b32abc3 Mon Sep 17 00:00:00 2001 From: Ron Eldor Date: Sun, 1 Apr 2018 15:59:58 +0300 Subject: [PATCH] Adjust more modules to new design Add `ecp.h` anf `timing.h` to new XXX_alt design --- ChangeLog | 2 +- include/mbedtls/ecp.h | 16 ++++++++-------- include/mbedtls/timing.h | 24 ++++++++---------------- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index a00ad1beb..4249de766 100644 --- a/ChangeLog +++ b/ChangeLog @@ -138,7 +138,7 @@ Changes * Put the Cryptographic API outside of the XXX_ALT macro check, so alternative header file will not need to redefined the same API, and to force alternative implementer to use the same API. - + = mbed TLS 2.7.0 branch released 2018-02-03 Security diff --git a/include/mbedtls/ecp.h b/include/mbedtls/ecp.h index d8c68233d..fe346141a 100644 --- a/include/mbedtls/ecp.h +++ b/include/mbedtls/ecp.h @@ -39,6 +39,10 @@ #define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH -0x4C00 /**< Signature is valid but shorter than the user-supplied length. */ #define MBEDTLS_ERR_ECP_HW_ACCEL_FAILED -0x4B80 /**< ECP hardware accelerator failed. */ +#ifdef __cplusplus +extern "C" { +#endif + #if !defined(MBEDTLS_ECP_ALT) /* * default mbed TLS elliptic curve arithmetic implementation @@ -48,10 +52,6 @@ * one.) */ -#ifdef __cplusplus -extern "C" { -#endif - /** * Domain parameters (curve, subgroup and generator) identifiers. * @@ -237,6 +237,10 @@ mbedtls_ecp_keypair; #define MBEDTLS_ECP_PF_UNCOMPRESSED 0 /**< Uncompressed point format */ #define MBEDTLS_ECP_PF_COMPRESSED 1 /**< Compressed point format */ +#else /* MBEDTLS_ECP_ALT */ +#include "ecp_alt.h" +#endif /* MBEDTLS_ECP_ALT */ + /* * Some other constants from RFC 4492 */ @@ -679,8 +683,4 @@ int mbedtls_ecp_self_test( int verbose ); } #endif -#else /* MBEDTLS_ECP_ALT */ -#include "ecp_alt.h" -#endif /* MBEDTLS_ECP_ALT */ - #endif /* ecp.h */ diff --git a/include/mbedtls/timing.h b/include/mbedtls/timing.h index 2c497bf4e..bbcb90688 100644 --- a/include/mbedtls/timing.h +++ b/include/mbedtls/timing.h @@ -30,16 +30,16 @@ #include MBEDTLS_CONFIG_FILE #endif -#if !defined(MBEDTLS_TIMING_ALT) -// Regular implementation -// - #include #ifdef __cplusplus extern "C" { #endif +#if !defined(MBEDTLS_TIMING_ALT) +// Regular implementation +// + /** * \brief timer structure */ @@ -58,6 +58,10 @@ typedef struct uint32_t fin_ms; } mbedtls_timing_delay_context; +#else /* MBEDTLS_TIMING_ALT */ +#include "timing_alt.h" +#endif /* MBEDTLS_TIMING_ALT */ + extern volatile int mbedtls_timing_alarmed; /** @@ -133,18 +137,6 @@ void mbedtls_timing_set_delay( void *data, uint32_t int_ms, uint32_t fin_ms ); */ int mbedtls_timing_get_delay( void *data ); -#ifdef __cplusplus -} -#endif - -#else /* MBEDTLS_TIMING_ALT */ -#include "timing_alt.h" -#endif /* MBEDTLS_TIMING_ALT */ - -#ifdef __cplusplus -extern "C" { -#endif - #if defined(MBEDTLS_SELF_TEST) /** * \brief Checkup routine