Skip to content

Commit

Permalink
core: LTC mpi_desc.c: update to mbedTLS 3.4.0 API
Browse files Browse the repository at this point in the history
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 <jens.wiklander@linaro.org>
Acked-By: Jerome Forissier <jerome.forissier@linaro.org>
  • Loading branch information
jenswi-linaro committed Oct 6, 2023
1 parent 33218e9 commit 982307b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/lib/libtomcrypt/mpi_desc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions core/lib/libtomcrypt/sub.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 982307b

Please sign in to comment.