Fix programs for recent ECDSA changes

This commit is contained in:
Manuel Pégourié-Gonnard 2015-03-31 13:32:39 +02:00
parent 8fce937a1a
commit 32076e66be
2 changed files with 6 additions and 15 deletions

View file

@ -56,11 +56,11 @@
#define ECPARAMS ecp_curve_list()->grp_id #define ECPARAMS ecp_curve_list()->grp_id
#endif #endif
#if !defined(POLARSSL_ECDSA_C) || \ #if !defined(POLARSSL_ECDSA_C) || !defined(POLARSSL_SHA256_C) || \
!defined(POLARSSL_ENTROPY_C) || !defined(POLARSSL_CTR_DRBG_C) !defined(POLARSSL_ENTROPY_C) || !defined(POLARSSL_CTR_DRBG_C)
int main( void ) int main( void )
{ {
polarssl_printf("POLARSSL_ECDSA_C and/or " polarssl_printf("POLARSSL_ECDSA_C and/or POLARSSL_SHA256_C and/or "
"POLARSSL_ENTROPY_C and/or POLARSSL_CTR_DRBG_C not defined\n"); "POLARSSL_ENTROPY_C and/or POLARSSL_CTR_DRBG_C not defined\n");
return( 0 ); return( 0 );
} }
@ -160,7 +160,7 @@ int main( int argc, char *argv[] )
polarssl_printf( " . Signing message..." ); polarssl_printf( " . Signing message..." );
fflush( stdout ); fflush( stdout );
if( ( ret = ecdsa_write_signature( &ctx_sign, if( ( ret = ecdsa_write_signature( &ctx_sign, POLARSSL_MD_SHA256,
hash, sizeof( hash ), hash, sizeof( hash ),
sig, &sig_len, sig, &sig_len,
ctr_drbg_random, &ctr_drbg ) ) != 0 ) ctr_drbg_random, &ctr_drbg ) ) != 0 )
@ -173,15 +173,6 @@ int main( int argc, char *argv[] )
dump_buf( " + Hash: ", hash, sizeof hash ); dump_buf( " + Hash: ", hash, sizeof hash );
dump_buf( " + Signature: ", sig, sig_len ); dump_buf( " + Signature: ", sig, sig_len );
/*
* Signature is serialized as defined by RFC 4492 p. 20,
* but one can also access 'r' and 's' directly from the context
*/
#ifdef POLARSSL_FS_IO
mpi_write_file( " r = ", &ctx_sign.r, 16, NULL );
mpi_write_file( " s = ", &ctx_sign.s, 16, NULL );
#endif
/* /*
* Transfer public information to verifying context * Transfer public information to verifying context
* *

View file

@ -652,7 +652,7 @@ int main( int argc, char *argv[] )
} }
#endif #endif
#if defined(POLARSSL_ECDSA_C) #if defined(POLARSSL_ECDSA_C) && defined(POLARSSL_SHA256_C)
if( todo.ecdsa ) if( todo.ecdsa )
{ {
ecdsa_context ecdsa; ecdsa_context ecdsa;
@ -674,7 +674,7 @@ int main( int argc, char *argv[] )
polarssl_snprintf( title, sizeof( title ), "ECDSA-%s", polarssl_snprintf( title, sizeof( title ), "ECDSA-%s",
curve_info->name ); curve_info->name );
TIME_PUBLIC( title, "sign", TIME_PUBLIC( title, "sign",
ret = ecdsa_write_signature( &ecdsa, buf, curve_info->size, ret = ecdsa_write_signature( &ecdsa, POLARSSL_MD_SHA256, buf, curve_info->size,
tmp, &sig_len, myrand, NULL ) ); tmp, &sig_len, myrand, NULL ) );
ecdsa_free( &ecdsa ); ecdsa_free( &ecdsa );
@ -687,7 +687,7 @@ int main( int argc, char *argv[] )
ecdsa_init( &ecdsa ); ecdsa_init( &ecdsa );
if( ecdsa_genkey( &ecdsa, curve_info->grp_id, myrand, NULL ) != 0 || if( ecdsa_genkey( &ecdsa, curve_info->grp_id, myrand, NULL ) != 0 ||
ecdsa_write_signature( &ecdsa, buf, curve_info->size, ecdsa_write_signature( &ecdsa, POLARSSL_MD_SHA256, buf, curve_info->size,
tmp, &sig_len, myrand, NULL ) != 0 ) tmp, &sig_len, myrand, NULL ) != 0 )
{ {
polarssl_exit( 1 ); polarssl_exit( 1 );