1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

Remove last non-static parts of known EC groups

This commit is contained in:
Manuel Pégourié-Gonnard
2013-12-06 12:41:30 +01:00
parent 731d08b406
commit 73cc01d7fa
2 changed files with 35 additions and 13 deletions

View File

@ -450,6 +450,17 @@ static inline void ecp_mpi_load( mpi *X, const t_uint *p, size_t len )
X->p = (t_uint *) p;
}
/*
* Set an MPI to static value 1
*/
static inline void ecp_mpi_set1( mpi *X )
{
static t_uint one[] = { 1 };
X->s = 1;
X->n = 1;
X->p = one;
}
/*
* Make group available from embedded constants
*/
@ -461,28 +472,20 @@ static int ecp_group_load( ecp_group *grp,
const t_uint *gy, size_t gylen,
const t_uint *n, size_t nlen)
{
int ret;
ecp_mpi_load( &grp->P, p, plen );
if( a != NULL )
ecp_mpi_load( &grp->A, a, alen );
else
MPI_CHK( mpi_sub_int( &grp->A, &grp->P, 3 ) );
ecp_mpi_load( &grp->B, b, blen );
ecp_mpi_load( &grp->N, n, nlen );
ecp_mpi_load( &grp->G.X, gx, gxlen );
ecp_mpi_load( &grp->G.Y, gy, gylen );
MPI_CHK( mpi_lset( &grp->G.Z, 1 ) );
ecp_mpi_set1( &grp->G.Z );
grp->pbits = mpi_msb( &grp->P );
grp->nbits = mpi_msb( &grp->N );
cleanup:
if( ret != 0 )
ecp_group_free( grp );
return( ret );
return( 0 );
}
#if defined(POLARSSL_ECP_NIST_OPTIM)