diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ac4e986e6..c3f9fc498 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -134,7 +134,7 @@ jobs: - uses: actions/checkout@v2 with: repository: ARMmbed/mbedtls - ref: v3.0.0 + ref: v3.1.0 path: third_party/mbedtls/repo - name: Build run: | diff --git a/src/core/meshcop/dtls.cpp b/src/core/meshcop/dtls.cpp index 7e0fc598d..700815237 100644 --- a/src/core/meshcop/dtls.cpp +++ b/src/core/meshcop/dtls.cpp @@ -59,7 +59,12 @@ namespace MeshCoP { RegisterLogModule("Dtls"); +#if (MBEDTLS_VERSION_NUMBER >= 0x03010000) +const uint16_t Dtls::sGroups[] = {MBEDTLS_SSL_IANA_TLS_GROUP_SECP256R1, MBEDTLS_SSL_IANA_TLS_GROUP_NONE}; +#else const mbedtls_ecp_group_id Dtls::sCurves[] = {MBEDTLS_ECP_DP_SECP256R1, MBEDTLS_ECP_DP_NONE}; +#endif + #if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) || defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) const int Dtls::sHashes[] = {MBEDTLS_MD_SHA256, MBEDTLS_MD_NONE}; #endif @@ -291,7 +296,11 @@ Error Dtls::Setup(bool aClient) mbedtls_ssl_conf_ciphersuites(&mConf, mCipherSuites); if (mCipherSuites[0] == MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8) { +#if (MBEDTLS_VERSION_NUMBER >= 0x03010000) + mbedtls_ssl_conf_groups(&mConf, sGroups); +#else mbedtls_ssl_conf_curves(&mConf, sCurves); +#endif #if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) || defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) mbedtls_ssl_conf_sig_hashes(&mConf, sHashes); #endif @@ -780,12 +789,12 @@ exit: #else -int Dtls::HandleMbedtlsExportKeys(void *aContext, +int Dtls::HandleMbedtlsExportKeys(void * aContext, const unsigned char *aMasterSecret, const unsigned char *aKeyBlock, - size_t aMacLength, - size_t aKeyLength, - size_t aIvLength) + size_t aMacLength, + size_t aKeyLength, + size_t aIvLength) { return static_cast(aContext)->HandleMbedtlsExportKeys(aMasterSecret, aKeyBlock, aMacLength, aKeyLength, aIvLength); @@ -793,14 +802,14 @@ int Dtls::HandleMbedtlsExportKeys(void *aContext, int Dtls::HandleMbedtlsExportKeys(const unsigned char *aMasterSecret, const unsigned char *aKeyBlock, - size_t aMacLength, - size_t aKeyLength, - size_t aIvLength) + size_t aMacLength, + size_t aKeyLength, + size_t aIvLength) { OT_UNUSED_VARIABLE(aMasterSecret); Crypto::Sha256::Hash kek; - Crypto::Sha256 sha256; + Crypto::Sha256 sha256; VerifyOrExit(mCipherSuites[0] == MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8); diff --git a/src/core/meshcop/dtls.hpp b/src/core/meshcop/dtls.hpp index 40db55168..dd16fdf23 100644 --- a/src/core/meshcop/dtls.hpp +++ b/src/core/meshcop/dtls.hpp @@ -357,7 +357,7 @@ private: #if !OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE static constexpr uint16_t kApplicationDataMaxLength = 1152; #else - static constexpr uint16_t kApplicationDataMaxLength = OPENTHREAD_CONFIG_DTLS_APPLICATION_DATA_MAX_LENGTH; + static constexpr uint16_t kApplicationDataMaxLength = OPENTHREAD_CONFIG_DTLS_APPLICATION_DATA_MAX_LENGTH; #endif static constexpr size_t kDtlsKeyBlockSize = 40; @@ -442,7 +442,12 @@ private: uint8_t mPsk[kPskMaxLength]; uint8_t mPskLength; +#if (MBEDTLS_VERSION_NUMBER >= 0x03010000) + static const uint16_t sGroups[]; +#else static const mbedtls_ecp_group_id sCurves[]; +#endif + #if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) || defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) static const int sHashes[]; #endif