mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 01:05:40 +01:00
Optimize unnecessary zeorizing in mbedtls_mpi_copy
Based on a contribution by Alexey Skalozub (https://github.com/ARMmbed/mbedtls/pull/405).
This commit is contained in:
parent
70ad839725
commit
4e4be7cf62
@ -1,5 +1,11 @@
|
|||||||
mbed TLS ChangeLog (Sorted per branch, date)
|
mbed TLS ChangeLog (Sorted per branch, date)
|
||||||
|
|
||||||
|
= mbed TLS 2.x.x branch released xxxx-xx-xx
|
||||||
|
|
||||||
|
Changes
|
||||||
|
* Optimize unnecessary zeroing in mbedtls_mpi_copy. Based on a contribution
|
||||||
|
by Alexey Skalozub.
|
||||||
|
|
||||||
= mbed TLS 2.7.0 branch released 2018-02-03
|
= mbed TLS 2.7.0 branch released 2018-02-03
|
||||||
|
|
||||||
Security
|
Security
|
||||||
|
@ -184,7 +184,7 @@ int mbedtls_mpi_shrink( mbedtls_mpi *X, size_t nblimbs )
|
|||||||
*/
|
*/
|
||||||
int mbedtls_mpi_copy( mbedtls_mpi *X, const mbedtls_mpi *Y )
|
int mbedtls_mpi_copy( mbedtls_mpi *X, const mbedtls_mpi *Y )
|
||||||
{
|
{
|
||||||
int ret;
|
int ret = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if( X == Y )
|
if( X == Y )
|
||||||
@ -203,9 +203,15 @@ int mbedtls_mpi_copy( mbedtls_mpi *X, const mbedtls_mpi *Y )
|
|||||||
|
|
||||||
X->s = Y->s;
|
X->s = Y->s;
|
||||||
|
|
||||||
|
if( X->n < i )
|
||||||
|
{
|
||||||
MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, i ) );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, i ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memset( X->p + i, 0, ( X->n - i ) * ciL );
|
||||||
|
}
|
||||||
|
|
||||||
memset( X->p, 0, X->n * ciL );
|
|
||||||
memcpy( X->p, Y->p, i * ciL );
|
memcpy( X->p, Y->p, i * ciL );
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
Loading…
Reference in New Issue
Block a user