From 982307bf61697e3e69084afedf306a0298c6e06a Mon Sep 17 00:00:00 2001 From: Jens Wiklander Date: Fri, 12 May 2023 13:02:21 +0200 Subject: [PATCH] core: LTC mpi_desc.c: update to mbedTLS 3.4.0 API MbedTLS 3.4.0 normally doesn't permit access to the internal fields of mbedtls_mpi. However, mpi_desc.c manipulates the internals of mbedtls_mpi so define MBEDTLS_ALLOW_PRIVATE_ACCESS to allow accesses to the internals of mbedtls_mpi. mbedtls_mpi_is_prime() is replaced by mbedtls_mpi_is_prime_ext() so switch to use that instead to implement isprime() in the internal LTC mpi_desc interface. Signed-off-by: Jens Wiklander Acked-By: Jerome Forissier --- core/lib/libtomcrypt/mpi_desc.c | 4 ++-- core/lib/libtomcrypt/sub.mk | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/lib/libtomcrypt/mpi_desc.c b/core/lib/libtomcrypt/mpi_desc.c index ff8dd13c79c..791db1e136e 100644 --- a/core/lib/libtomcrypt/mpi_desc.c +++ b/core/lib/libtomcrypt/mpi_desc.c @@ -602,9 +602,9 @@ static int rng_read(void *ignored __unused, unsigned char *buf, size_t blen) return 0; } -static int isprime(void *a, int b __unused, int *c) +static int isprime(void *a, int b, int *c) { - int res = mbedtls_mpi_is_prime(a, rng_read, NULL); + int res = mbedtls_mpi_is_prime_ext(a, b, rng_read, NULL); if (res == MBEDTLS_ERR_MPI_ALLOC_FAILED) return CRYPT_MEM; diff --git a/core/lib/libtomcrypt/sub.mk b/core/lib/libtomcrypt/sub.mk index 29ad4fea49e..6e0d58e1e7b 100644 --- a/core/lib/libtomcrypt/sub.mk +++ b/core/lib/libtomcrypt/sub.mk @@ -148,6 +148,7 @@ srcs-$(_CFG_CORE_LTC_X25519) += x25519.c srcs-$(_CFG_CORE_LTC_ED25519) += ed25519.c ifeq ($(_CFG_CORE_LTC_ACIPHER),y) srcs-y += mpi_desc.c +cppflags-mpi_desc.c-y += -DMBEDTLS_ALLOW_PRIVATE_ACCESS endif srcs-y += tomcrypt.c