mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-02-03 00:00:59 +00:00
Add curve25519 to the benchmark program
This commit is contained in:
parent
e579dab5f0
commit
85391f2a65
|
@ -704,6 +704,9 @@ int main( int argc, char *argv[] )
|
||||||
if( todo.ecdh )
|
if( todo.ecdh )
|
||||||
{
|
{
|
||||||
ecdh_context ecdh;
|
ecdh_context ecdh;
|
||||||
|
#if defined(POLARSSL_ECP_DP_M255_ENABLED)
|
||||||
|
mpi z;
|
||||||
|
#endif
|
||||||
const ecp_curve_info *curve_info;
|
const ecp_curve_info *curve_info;
|
||||||
size_t olen;
|
size_t olen;
|
||||||
|
|
||||||
|
@ -732,6 +735,27 @@ int main( int argc, char *argv[] )
|
||||||
ecdh_free( &ecdh );
|
ecdh_free( &ecdh );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Curve25519 needs to be handled separately */
|
||||||
|
#if defined(POLARSSL_ECP_DP_M255_ENABLED)
|
||||||
|
ecdh_init( &ecdh );
|
||||||
|
mpi_init( &z );
|
||||||
|
|
||||||
|
if( ecp_use_known_dp( &ecdh.grp, POLARSSL_ECP_DP_M255 ) != 0 ||
|
||||||
|
ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Qp, myrand, NULL ) != 0 )
|
||||||
|
{
|
||||||
|
exit( 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
TIME_PUBLIC( "ECDHE-Curve25519", "handshake",
|
||||||
|
ret |= ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Q,
|
||||||
|
myrand, NULL );
|
||||||
|
ret |= ecdh_compute_shared( &ecdh.grp, &z, &ecdh.Qp, &ecdh.d,
|
||||||
|
myrand, NULL ) );
|
||||||
|
|
||||||
|
ecdh_free( &ecdh );
|
||||||
|
mpi_free( &z );
|
||||||
|
#endif
|
||||||
|
|
||||||
for( curve_info = ecp_curve_list();
|
for( curve_info = ecp_curve_list();
|
||||||
curve_info->grp_id != POLARSSL_ECP_DP_NONE;
|
curve_info->grp_id != POLARSSL_ECP_DP_NONE;
|
||||||
curve_info++ )
|
curve_info++ )
|
||||||
|
@ -756,6 +780,27 @@ int main( int argc, char *argv[] )
|
||||||
myrand, NULL ) );
|
myrand, NULL ) );
|
||||||
ecdh_free( &ecdh );
|
ecdh_free( &ecdh );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Curve25519 needs to be handled separately */
|
||||||
|
#if defined(POLARSSL_ECP_DP_M255_ENABLED)
|
||||||
|
ecdh_init( &ecdh );
|
||||||
|
mpi_init( &z );
|
||||||
|
|
||||||
|
if( ecp_use_known_dp( &ecdh.grp, POLARSSL_ECP_DP_M255 ) != 0 ||
|
||||||
|
ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Qp,
|
||||||
|
myrand, NULL ) != 0 ||
|
||||||
|
ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Q, myrand, NULL ) != 0 )
|
||||||
|
{
|
||||||
|
exit( 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
TIME_PUBLIC( "ECDH-Curve25519", "handshake",
|
||||||
|
ret |= ecdh_compute_shared( &ecdh.grp, &z, &ecdh.Qp, &ecdh.d,
|
||||||
|
myrand, NULL ) );
|
||||||
|
|
||||||
|
ecdh_free( &ecdh );
|
||||||
|
mpi_free( &z );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue