mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-16 04:20:49 +00:00
Exp mod: use assignment instead memcpy
memcpy() has the advantage of making the reader stop and arguably signal that the shallow copy here is intentional. But that hinges on having the right amount of & and the right size. An assignment is clearer and less risky. Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
parent
701ae1d3d9
commit
576087d836
@ -1630,10 +1630,10 @@ int mbedtls_mpi_exp_mod(mbedtls_mpi *X, const mbedtls_mpi *A,
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_core_get_mont_r2_unsafe(&RR, N));
|
||||
|
||||
if (prec_RR != NULL) {
|
||||
memcpy(prec_RR, &RR, sizeof(mbedtls_mpi));
|
||||
*prec_RR = RR;
|
||||
}
|
||||
} else {
|
||||
memcpy(&RR, prec_RR, sizeof(mbedtls_mpi));
|
||||
RR = *prec_RR;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1642,7 +1642,7 @@ int mbedtls_mpi_exp_mod(mbedtls_mpi *X, const mbedtls_mpi *A,
|
||||
if (E->n == 0) {
|
||||
mbedtls_mpi_lset(&E_core, 0);
|
||||
} else {
|
||||
memcpy(&E_core, E, sizeof(mbedtls_mpi));
|
||||
E_core = *E;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user