mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-23 15:55:10 +01:00
Basic tests for ECDSA.
This commit is contained in:
parent
3aeb5a7192
commit
d1c7150bf5
3 changed files with 53 additions and 0 deletions
37
tests/suites/test_suite_ecdsa.function
Normal file
37
tests/suites/test_suite_ecdsa.function
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
BEGIN_HEADER
|
||||
#include <polarssl/ecdsa.h>
|
||||
END_HEADER
|
||||
|
||||
BEGIN_DEPENDENCIES
|
||||
depends_on:POLARSSL_ECDSA_C:POLARSSL_ECP_C:POLARSSL_BIGNUM_C
|
||||
END_DEPENDENCIES
|
||||
|
||||
BEGIN_CASE
|
||||
ecdsa_sign_verify:id
|
||||
{
|
||||
ecp_group grp;
|
||||
ecp_point Q;
|
||||
mpi d, r, s;
|
||||
rnd_pseudo_info rnd_info;
|
||||
unsigned char buf[66];
|
||||
|
||||
ecp_group_init( &grp );
|
||||
ecp_point_init( &Q );
|
||||
mpi_init( &d ); mpi_init( &r ); mpi_init( &s );
|
||||
memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) );
|
||||
|
||||
/* prepare material for signature */
|
||||
TEST_ASSERT( rnd_pseudo_rand( &rnd_info, buf, sizeof( buf ) ) == 0 );
|
||||
TEST_ASSERT( ecp_use_known_dp( &grp, POLARSSL_ECP_DP_{id} ) == 0 );
|
||||
TEST_ASSERT( ecp_gen_keypair( &grp, &d, &Q, &rnd_pseudo_rand, &rnd_info )
|
||||
== 0 );
|
||||
|
||||
TEST_ASSERT( ecdsa_sign( &grp, &r, &s, &d, buf, sizeof( buf ),
|
||||
&rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
TEST_ASSERT( ecdsa_verify( &grp, buf, sizeof( buf ), &Q, &r, &s ) == 0 );
|
||||
|
||||
ecp_group_free( &grp );
|
||||
ecp_point_free( &Q );
|
||||
mpi_free( &d ); mpi_free( &r ); mpi_free( &s );
|
||||
}
|
||||
END_CASE
|
||||
Loading…
Add table
Add a link
Reference in a new issue