Skip to content

Commit

Permalink
libtuee: allow NULL output coefficients in TEE_BigIntComputeExtendedG…
Browse files Browse the repository at this point in the history
…cd()

Fix TEE_BigIntComputeExtendedGcd() for when only one of u and v output
coefficients reference is NULL as allowed by the GP TEE Internal Core API
specification.

Reported-by: Stefan Schmidt <[email protected]>
Closes: OP-TEE#7217
Signed-off-by: Etienne Carriere <[email protected]>
Reviewed-by: Jerome Forissier <[email protected]>
Reviewed-by: Jens Wiklander <[email protected]>
  • Loading branch information
etienne-lms authored and jforissier committed Jan 13, 2025
1 parent defc9e0 commit 703ebb7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/libutee/tee_api_arith_mpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -864,8 +864,10 @@ void TEE_BigIntComputeExtendedGcd(TEE_BigInt *gcd, TEE_BigInt *u,
mpi_u.s *= s1;
mpi_v.s *= s2;

MPI_CHECK(copy_mpi_to_bigint(&mpi_u, u));
MPI_CHECK(copy_mpi_to_bigint(&mpi_v, v));
if (u)
MPI_CHECK(copy_mpi_to_bigint(&mpi_u, u));
if (v)
MPI_CHECK(copy_mpi_to_bigint(&mpi_v, v));
mbedtls_mpi_free(&mpi_u);
mbedtls_mpi_free(&mpi_v);
}
Expand Down

0 comments on commit 703ebb7

Please sign in to comment.