From 05d0e51bb1cdace99da6571967af1c9adc3b74f8 Mon Sep 17 00:00:00 2001 From: Ron Eldor Date: Mon, 16 Apr 2018 17:40:04 +0300 Subject: [PATCH] Minor modifications for alt support in des and ecp 1. Add 3des context to be allowed for alternative defintion 2. Move some ecp structs, to disallow alternative definition of them, as other modules rely on them --- include/mbedtls/des.h | 8 ++++---- include/mbedtls/ecp.h | 48 +++++++++++++++++++++---------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/include/mbedtls/des.h b/include/mbedtls/des.h index b0a82df9b..6eb7d03ba 100644 --- a/include/mbedtls/des.h +++ b/include/mbedtls/des.h @@ -67,10 +67,6 @@ typedef struct } mbedtls_des_context; -#else /* MBEDTLS_DES_ALT */ -#include "des_alt.h" -#endif /* MBEDTLS_DES_ALT */ - /** * \brief Triple-DES context structure */ @@ -80,6 +76,10 @@ typedef struct } mbedtls_des3_context; +#else /* MBEDTLS_DES_ALT */ +#include "des_alt.h" +#endif /* MBEDTLS_DES_ALT */ + /** * \brief Initialize DES context * diff --git a/include/mbedtls/ecp.h b/include/mbedtls/ecp.h index 1bc5ac9e6..45a2452a1 100644 --- a/include/mbedtls/ecp.h +++ b/include/mbedtls/ecp.h @@ -43,15 +43,6 @@ extern "C" { #endif -#if !defined(MBEDTLS_ECP_ALT) -/* - * default mbed TLS elliptic curve arithmetic implementation - * - * (in case MBEDTLS_ECP_ALT is defined then the developer has to provide an - * alternative implementation for the whole module and it will replace this - * one.) - */ - /** * Domain parameters (curve, subgroup and generator) identifiers. * @@ -113,6 +104,15 @@ typedef struct } mbedtls_ecp_point; +#if !defined(MBEDTLS_ECP_ALT) +/* + * default mbed TLS elliptic curve arithmetic implementation + * + * (in case MBEDTLS_ECP_ALT is defined then the developer has to provide an + * alternative implementation for the whole module and it will replace this + * one.) + */ + /** * \brief ECP group structure * @@ -157,21 +157,6 @@ typedef struct } mbedtls_ecp_group; -/** - * \brief ECP key pair structure - * - * A generic key pair that could be used for ECDSA, fixed ECDH, etc. - * - * \note Members purposefully in the same order as struc mbedtls_ecdsa_context. - */ -typedef struct -{ - mbedtls_ecp_group grp; /*!< Elliptic curve and base point */ - mbedtls_mpi d; /*!< our secret value */ - mbedtls_ecp_point Q; /*!< our public value */ -} -mbedtls_ecp_keypair; - /** * \name SECTION: Module settings * @@ -235,6 +220,21 @@ mbedtls_ecp_keypair; #include "ecp_alt.h" #endif /* MBEDTLS_ECP_ALT */ +/** + * \brief ECP key pair structure + * + * A generic key pair that could be used for ECDSA, fixed ECDH, etc. + * + * \note Members purposefully in the same order as struc mbedtls_ecdsa_context. + */ +typedef struct +{ + mbedtls_ecp_group grp; /*!< Elliptic curve and base point */ + mbedtls_mpi d; /*!< our secret value */ + mbedtls_ecp_point Q; /*!< our public value */ +} +mbedtls_ecp_keypair; + /* * Point formats, from RFC 4492's enum ECPointFormat */