From 396d23cd062a8ebb29137633973747897a26eb7b Mon Sep 17 00:00:00 2001 From: Eduardo Montoya Date: Wed, 8 Jul 2020 04:05:19 +0200 Subject: [PATCH] [dtls] explicitly configure ECJPAKE parameters (#5192) This commit: - Uses the mbedtls API to explicitly fix the number of used curves to one when using ECJPAKE, as required by Section 3 of draft-cragie-tls-ecjpake-01. - Uses the mbedtls API to explicitly remove the Signature Hash Algorithms when using ECJPAKE. --- src/core/meshcop/dtls.cpp | 12 ++++++++++++ src/core/meshcop/dtls.hpp | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/src/core/meshcop/dtls.cpp b/src/core/meshcop/dtls.cpp index e4041278a..2569ed91a 100644 --- a/src/core/meshcop/dtls.cpp +++ b/src/core/meshcop/dtls.cpp @@ -56,6 +56,11 @@ namespace ot { namespace MeshCoP { +const mbedtls_ecp_group_id Dtls::sCurves[] = {MBEDTLS_ECP_DP_SECP256R1, MBEDTLS_ECP_DP_NONE}; +#ifdef MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED +const int Dtls::sHashes[] = {MBEDTLS_MD_NONE}; +#endif + Dtls::Dtls(Instance &aInstance, bool aLayerTwoSecurity) : InstanceLocator(aInstance) , mState(kStateClosed) @@ -286,6 +291,13 @@ otError Dtls::Setup(bool aClient) OT_ASSERT(mCipherSuites[1] == 0); mbedtls_ssl_conf_ciphersuites(&mConf, mCipherSuites); + if (mCipherSuites[0] == MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8) + { + mbedtls_ssl_conf_curves(&mConf, sCurves); +#ifdef MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED + mbedtls_ssl_conf_sig_hashes(&mConf, sHashes); +#endif + } mbedtls_ssl_conf_export_keys_cb(&mConf, HandleMbedtlsExportKeys, this); mbedtls_ssl_conf_handshake_timeout(&mConf, 8000, 60000); mbedtls_ssl_conf_dbg(&mConf, HandleMbedtlsDebug, this); diff --git a/src/core/meshcop/dtls.hpp b/src/core/meshcop/dtls.hpp index 748a132de..9fc3d2b27 100644 --- a/src/core/meshcop/dtls.hpp +++ b/src/core/meshcop/dtls.hpp @@ -413,6 +413,11 @@ private: uint8_t mPsk[kPskMaxLength]; uint8_t mPskLength; + static const mbedtls_ecp_group_id sCurves[]; +#ifdef MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED + static const int sHashes[]; +#endif + #if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE #ifdef MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED const uint8_t * mCaChainSrc;