mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 11:05:40 +01:00
Added ecp_XXX_read_string()
This commit is contained in:
parent
7cfcea349c
commit
847395a8a9
@ -150,7 +150,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Initialize a point
|
||||
* \brief Initialize a point (as zero)
|
||||
*/
|
||||
void ecp_point_init( ecp_point *pt );
|
||||
|
||||
@ -180,6 +180,36 @@ void ecp_set_zero( ecp_point *pt );
|
||||
*/
|
||||
int ecp_copy( ecp_point *P, const ecp_point *Q );
|
||||
|
||||
/**
|
||||
* \brief Import a non-zero point from two ASCII strings
|
||||
*
|
||||
* \param P Destination point
|
||||
* \param radix Input numeric base
|
||||
* \param x First affine coordinate as a null-terminated string
|
||||
* \param y Second affine coordinate as a null-terminated string
|
||||
*
|
||||
* \return 0 if successful, or a POLARSSL_ERR_MPI_XXX error code
|
||||
*/
|
||||
int ecp_point_read_string( ecp_point *P, int radix,
|
||||
const char *x, const char *y );
|
||||
|
||||
/**
|
||||
* \brief Import an ECP group from null-terminated ASCII strings
|
||||
*
|
||||
* \param grp Destination group
|
||||
* \param radix Input numric base
|
||||
* \param p Prime modulus of the base field
|
||||
* \param b Constant term in the equation
|
||||
* \param gx The generator's X coordinate
|
||||
* \param gy The generator's Y coordinate
|
||||
* \param n The generator's order
|
||||
*
|
||||
* \return 0 if successful, or a POLARSSL_ERR_MPI_XXX error code
|
||||
*/
|
||||
int ecp_group_read_string( ecp_group *grp, int radix,
|
||||
const char *p, const char *b,
|
||||
const char *gx, const char *gy, const char *n);
|
||||
|
||||
/**
|
||||
* \brief Addition: R = P + Q
|
||||
*
|
||||
|
@ -101,6 +101,40 @@ cleanup:
|
||||
return( ret );
|
||||
}
|
||||
|
||||
/*
|
||||
* Import a non-zero point from ASCII strings
|
||||
*/
|
||||
int ecp_point_read_string( ecp_point *P, int radix,
|
||||
const char *x, const char *y )
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
P->is_zero = 0;
|
||||
MPI_CHK( mpi_read_string( &P->X, radix, x ) );
|
||||
MPI_CHK( mpi_read_string( &P->Y, radix, y ) );
|
||||
|
||||
cleanup:
|
||||
return( ret );
|
||||
}
|
||||
|
||||
/*
|
||||
* Import an ECP group from ASCII strings
|
||||
*/
|
||||
int ecp_group_read_string( ecp_group *grp, int radix,
|
||||
const char *p, const char *b,
|
||||
const char *gx, const char *gy, const char *n)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
MPI_CHK( mpi_read_string( &grp->P, radix, p ) );
|
||||
MPI_CHK( mpi_read_string( &grp->B, radix, b ) );
|
||||
MPI_CHK( ecp_point_read_string( &grp->G, radix, gx, gy ) );
|
||||
MPI_CHK( mpi_read_string( &grp->N, radix, n ) );
|
||||
|
||||
cleanup:
|
||||
return( ret );
|
||||
}
|
||||
|
||||
/*
|
||||
* Addition: R = P + Q, generic case (P != Q, P != 0, Q != 0, R != 0)
|
||||
* Cf SEC1 v2 p. 7, item 4
|
||||
|
Loading…
Reference in New Issue
Block a user