From 50319bb03c71128399f3d3bc7034ca931efa5337 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Wed, 20 May 2020 12:06:07 +1000 Subject: [PATCH] wpa_supplicant: Allow building with mbedTLS integration but no hardware MPI Also disable the relevant function in bignum.h based on config, so fails at compile not link time. Closes https://github.com/espressif/esp-idf/issues/5321 --- components/mbedtls/port/include/mbedtls/bignum.h | 10 ++++++---- components/wpa_supplicant/src/crypto/crypto_mbedtls.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/components/mbedtls/port/include/mbedtls/bignum.h b/components/mbedtls/port/include/mbedtls/bignum.h index 23cd56348..a317c4560 100644 --- a/components/mbedtls/port/include/mbedtls/bignum.h +++ b/components/mbedtls/port/include/mbedtls/bignum.h @@ -1,4 +1,4 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,10 +11,10 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef __ESP_MBEDTLS_BIGNUM_H__ -#define __ESP_MBEDTLS_BIGNUM_H__ +#pragma once #include_next "mbedtls/bignum.h" +#include "sdkconfig.h" /** * This is a wrapper for the main mbedtls/bignum.h. This wrapper @@ -58,6 +58,8 @@ void esp_mpi_acquire_hardware(void); */ void esp_mpi_release_hardware(void); +#if CONFIG_MBEDTLS_HARDWARE_MPI + /* @brief MPI modular mupltiplication function * * Calculates Z = (X * Y) mod M using MPI hardware acceleration. @@ -75,4 +77,4 @@ void esp_mpi_release_hardware(void); */ int esp_mpi_mul_mpi_mod(mbedtls_mpi *Z, const mbedtls_mpi *X, const mbedtls_mpi *Y, const mbedtls_mpi *M); -#endif +#endif // CONFIG_MBEDTLS_HARDWARE_MPI diff --git a/components/wpa_supplicant/src/crypto/crypto_mbedtls.c b/components/wpa_supplicant/src/crypto/crypto_mbedtls.c index 4062b1615..2024b0b89 100644 --- a/components/wpa_supplicant/src/crypto/crypto_mbedtls.c +++ b/components/wpa_supplicant/src/crypto/crypto_mbedtls.c @@ -160,7 +160,7 @@ int crypto_bignum_mulmod(const struct crypto_bignum *a, struct crypto_bignum *d) { int res; -#if ALLOW_EVEN_MOD // Must enable this macro if c is even. +#if ALLOW_EVEN_MOD || !CONFIG_MBEDTLS_HARDWARE_MPI // Must enable ALLOW_EVEN_MOD if c is even mbedtls_mpi temp; mbedtls_mpi_init(&temp);