[meshcop] update the DEPRECATED function mbedtls_ssl_conf_curves (#7415)

The commit updates the `mbedtls_ssl_conf_curves` with the new
alternative - `mbedtls_ssl_conf_groups`. The API has been deprecated
in `mbedtls-3.1` and will be removed in a future release. The code is
also kept backward compatible to support older versions.
This commit is contained in:
AdityaHPatwardhan
2022-02-18 16:12:12 -08:00
committed by GitHub
parent 52777e8f8d
commit ff848e7a20
3 changed files with 24 additions and 10 deletions
+1 -1
View File
@@ -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: |
+17 -8
View File
@@ -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<Dtls *>(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);
+6 -1
View File
@@ -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