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>
diff --git a/library/bignum.c b/library/bignum.c
index 674aab7..42b735f 100644
--- a/library/bignum.c
+++ b/library/bignum.c
@@ -1630,10 +1630,10 @@
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 @@
if (E->n == 0) {
mbedtls_mpi_lset(&E_core, 0);
} else {
- memcpy(&E_core, E, sizeof(mbedtls_mpi));
+ E_core = *E;
}
/*