1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-12-24 17:41:01 +03:00

Forbid uninteresting edge cases

A == N (as pointers) will not happen in pratice: in our context, it
would mean we know at compile time that A == N (as values), and we
wouldn't be calling this function if we knew that already.

N == 1 when I != NULL is also not going to happen: we don't care about
operations mod 1.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
Manuel Pégourié-Gonnard
2025-07-17 09:39:55 +02:00
parent 7fba466826
commit 5972096114

View File

@@ -825,7 +825,9 @@ void mbedtls_mpi_core_from_mont_rep(mbedtls_mpi_uint *X,
/** Compute GCD(A, N) and optionally the inverse of A mod N if it exists.
*
* Requires N to be odd, and 0 <= A <= N.
* When I != NULL, N (the modulus) must not be 1.
*
* A and N may not alias each other.
* When I == NULL (computing only the GCD), G may alias A or N.
* When I != NULL (computing the modular inverse), G or I may alias A
* but none of them may alias N (the modulus).