mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-24 00:06:32 +01:00
Merge ecdsa_write_signature{,_det}() together
This commit is contained in:
parent
63e931902b
commit
dfdcac9d51
6 changed files with 41 additions and 91 deletions
|
|
@ -132,12 +132,12 @@ exit:
|
|||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
/* BEGIN_CASE depends_on:POLARSSL_SHA256_C */
|
||||
void ecdsa_write_read_random( int id )
|
||||
{
|
||||
ecdsa_context ctx;
|
||||
rnd_pseudo_info rnd_info;
|
||||
unsigned char hash[66];
|
||||
unsigned char hash[32];
|
||||
unsigned char sig[200];
|
||||
size_t sig_len, i;
|
||||
|
||||
|
|
@ -153,7 +153,8 @@ void ecdsa_write_read_random( int id )
|
|||
TEST_ASSERT( ecdsa_genkey( &ctx, id, &rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
|
||||
/* generate and write signature, then read and verify it */
|
||||
TEST_ASSERT( ecdsa_write_signature( &ctx, hash, sizeof( hash ),
|
||||
TEST_ASSERT( ecdsa_write_signature( &ctx, POLARSSL_MD_SHA256,
|
||||
hash, sizeof( hash ),
|
||||
sig, &sig_len, &rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
TEST_ASSERT( ecdsa_read_signature( &ctx, hash, sizeof( hash ),
|
||||
sig, sig_len ) == 0 );
|
||||
|
|
@ -191,35 +192,3 @@ exit:
|
|||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:POLARSSL_ECDSA_DETERMINISTIC */
|
||||
void ecdsa_write_read_det_random( int id, int md_alg )
|
||||
{
|
||||
ecdsa_context ctx;
|
||||
rnd_pseudo_info rnd_info;
|
||||
unsigned char msg[100];
|
||||
unsigned char hash[POLARSSL_MD_MAX_SIZE];
|
||||
unsigned char sig[200];
|
||||
size_t sig_len;
|
||||
|
||||
ecdsa_init( &ctx );
|
||||
memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) );
|
||||
memset( hash, 0, sizeof( hash ) );
|
||||
memset( sig, 0x2a, sizeof( sig ) );
|
||||
|
||||
/* prepare material for signature */
|
||||
TEST_ASSERT( rnd_pseudo_rand( &rnd_info, msg, sizeof( msg ) ) == 0 );
|
||||
md( md_info_from_type( md_alg ), msg, sizeof( msg ), hash );
|
||||
|
||||
/* generate signing key */
|
||||
TEST_ASSERT( ecdsa_genkey( &ctx, id, &rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
|
||||
/* generate and write signature, then read and verify it */
|
||||
TEST_ASSERT( ecdsa_write_signature_det( &ctx, hash, sizeof( hash ),
|
||||
sig, &sig_len, md_alg ) == 0 );
|
||||
TEST_ASSERT( ecdsa_read_signature( &ctx, hash, sizeof( hash ),
|
||||
sig, sig_len ) == 0 );
|
||||
|
||||
exit:
|
||||
ecdsa_free( &ctx );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue