mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 09:15:43 +01:00
gen_prime: ensure X = 3 mod 4 always (2x speed-up)
This commit is contained in:
parent
d1bac4ae55
commit
711507a726
@ -1969,9 +1969,9 @@ int mpi_gen_prime( mpi *X, size_t nbits, int dh_flag,
|
|||||||
if( ret != POLARSSL_ERR_MPI_NOT_ACCEPTABLE )
|
if( ret != POLARSSL_ERR_MPI_NOT_ACCEPTABLE )
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
MPI_CHK( mpi_add_int( &Y, X, 1 ) );
|
/* Keep X = 3 mod 4 */
|
||||||
MPI_CHK( mpi_add_int( X, X, 2 ) );
|
MPI_CHK( mpi_add_int( X, X, 4 ) );
|
||||||
MPI_CHK( mpi_shift_r( &Y, 1 ) );
|
MPI_CHK( mpi_add_int( &Y, &Y, 2 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user