Fix bignum for 64-bit machine.
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
2017-10-04 NIIBE Yutaka <gniibe@fsij.org>
|
2017-10-04 NIIBE Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
* src/main.c (gnuk_malloc, gnuk_free): Fix for 64-bit.
|
* polarssl/library/bignum.c (mpi_div_mpi): Fix for 64-bit machine.
|
||||||
|
|
||||||
|
* src/main.c (gnuk_malloc, gnuk_free): Fix for 64-bit machine.
|
||||||
|
|
||||||
* src/stack-def.h (SIZE_3): Tweak the size.
|
* src/stack-def.h (SIZE_3): Tweak the size.
|
||||||
|
|
||||||
@@ -46,7 +48,7 @@
|
|||||||
|
|
||||||
* src/usb-ccid.c (INTR_REQ_USB): Fix for GNU/Linux.
|
* src/usb-ccid.c (INTR_REQ_USB): Fix for GNU/Linux.
|
||||||
|
|
||||||
* library/bignum.c (mpi_montsqr): Easy C implementation.
|
* polarssl/library/bignum.c (mpi_montsqr): Easy C implementation.
|
||||||
|
|
||||||
2017-09-30 NIIBE Yutaka <gniibe@fsij.org>
|
2017-09-30 NIIBE Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
@@ -113,7 +115,8 @@
|
|||||||
|
|
||||||
* src/ec_p256k1.c (coefficient_a): Remove.
|
* src/ec_p256k1.c (coefficient_a): Remove.
|
||||||
|
|
||||||
* library/bignum.c (mpi_fill_pseudo_random): Fix for 64-bit.
|
* polarssl/library/bignum.c (mpi_fill_pseudo_random): Fix for
|
||||||
|
64-bit machine.
|
||||||
|
|
||||||
* src/call-rsa.c (rsa_decrypt): Fix for 64-bit machine.
|
* src/call-rsa.c (rsa_decrypt): Fix for 64-bit machine.
|
||||||
|
|
||||||
|
|||||||
@@ -1142,9 +1142,9 @@ static t_uint int_div_int(t_uint u1, t_uint u0, t_uint d, t_uint *r)
|
|||||||
*/
|
*/
|
||||||
if(( 0 == d ) || ( u1 >= d ))
|
if(( 0 == d ) || ( u1 >= d ))
|
||||||
{
|
{
|
||||||
if (r != NULL) *r = (~0);
|
if (r != NULL) *r = (~0UL);
|
||||||
|
|
||||||
return (~0);
|
return (~0UL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(POLARSSL_HAVE_UDBL)
|
#if defined(POLARSSL_HAVE_UDBL)
|
||||||
@@ -1270,7 +1270,7 @@ int mpi_div_mpi( mpi *Q, mpi *R, const mpi *A, const mpi *B )
|
|||||||
for( i = n; i > t ; i-- )
|
for( i = n; i > t ; i-- )
|
||||||
{
|
{
|
||||||
if( X.p[i] >= Y.p[t] )
|
if( X.p[i] >= Y.p[t] )
|
||||||
Z.p[i - t - 1] = ~0;
|
Z.p[i - t - 1] = ~0UL;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Z.p[i - t - 1] = int_div_int( X.p[i], X.p[i-1], Y.p[t], NULL);
|
Z.p[i - t - 1] = int_div_int( X.p[i], X.p[i-1], Y.p[t], NULL);
|
||||||
@@ -1297,7 +1297,7 @@ int mpi_div_mpi( mpi *Q, mpi *R, const mpi *A, const mpi *B )
|
|||||||
MPI_CHK( mpi_shift_l( &T1, biL * (i - t - 1) ) );
|
MPI_CHK( mpi_shift_l( &T1, biL * (i - t - 1) ) );
|
||||||
MPI_CHK( mpi_sub_mpi( &X, &X, &T1 ) );
|
MPI_CHK( mpi_sub_mpi( &X, &X, &T1 ) );
|
||||||
|
|
||||||
if( mpi_cmp_int( &X, 0 ) < 0 )
|
while( mpi_cmp_int( &X, 0 ) < 0 )
|
||||||
{
|
{
|
||||||
MPI_CHK( mpi_copy( &T1, &Y ) );
|
MPI_CHK( mpi_copy( &T1, &Y ) );
|
||||||
MPI_CHK( mpi_shift_l( &T1, biL * (i - t - 1) ) );
|
MPI_CHK( mpi_shift_l( &T1, biL * (i - t - 1) ) );
|
||||||
|
|||||||
Reference in New Issue
Block a user