tinyCrypt: Share ECDH secret calculation code-path
This commit is contained in:
parent
75f12d1eb9
commit
a3c2c1712c
3 changed files with 21 additions and 20 deletions
|
@ -3573,14 +3573,6 @@ static int ssl_out_client_key_exchange_write( mbedtls_ssl_context *ssl,
|
||||||
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
|
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !uECC_shared_secret( ssl->handshake->ecdh_peerkey,
|
|
||||||
ssl->handshake->ecdh_privkey,
|
|
||||||
ssl->handshake->premaster,
|
|
||||||
uecc_curve ) )
|
|
||||||
{
|
|
||||||
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO: Write the client share. */
|
/* TODO: Write the client share. */
|
||||||
((void) p);
|
((void) p);
|
||||||
((void) end);
|
((void) end);
|
||||||
|
|
|
@ -4204,20 +4204,9 @@ static int ssl_in_client_key_exchange_parse( mbedtls_ssl_context *ssl,
|
||||||
mbedtls_ssl_suite_get_key_exchange( ciphersuite_info )
|
mbedtls_ssl_suite_get_key_exchange( ciphersuite_info )
|
||||||
== MBEDTLS_KEY_EXCHANGE_ECDHE_RSA )
|
== MBEDTLS_KEY_EXCHANGE_ECDHE_RSA )
|
||||||
{
|
{
|
||||||
const struct uECC_Curve_t * uecc_curve = uECC_secp256r1();
|
if( mbedtls_ssl_ecdh_read_peerkey( ssl, &p, end ) != 0 )
|
||||||
|
|
||||||
ret = mbedtls_ssl_ecdh_read_peerkey( ssl, &p, end );
|
|
||||||
if( ret != 0 )
|
|
||||||
return( ret );
|
|
||||||
|
|
||||||
if( !uECC_shared_secret( ssl->handshake->ecdh_peerkey,
|
|
||||||
ssl->handshake->ecdh_privkey,
|
|
||||||
ssl->handshake->premaster,
|
|
||||||
uecc_curve ) )
|
|
||||||
{
|
|
||||||
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
|
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
|
#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
|
||||||
|
|
|
@ -1701,6 +1701,26 @@ int mbedtls_ssl_build_pms( mbedtls_ssl_context *ssl )
|
||||||
mbedtls_ssl_ciphersuite_handle_t ciphersuite_info =
|
mbedtls_ssl_ciphersuite_handle_t ciphersuite_info =
|
||||||
mbedtls_ssl_handshake_get_ciphersuite( ssl->handshake );
|
mbedtls_ssl_handshake_get_ciphersuite( ssl->handshake );
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_TINYCRYPT)
|
||||||
|
if( mbedtls_ssl_suite_get_key_exchange( ciphersuite_info )
|
||||||
|
== MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA ||
|
||||||
|
mbedtls_ssl_suite_get_key_exchange( ciphersuite_info )
|
||||||
|
== MBEDTLS_KEY_EXCHANGE_ECDHE_RSA )
|
||||||
|
{
|
||||||
|
const struct uECC_Curve_t * uecc_curve = uECC_secp256r1();
|
||||||
|
|
||||||
|
if( !uECC_shared_secret( ssl->handshake->ecdh_peerkey,
|
||||||
|
ssl->handshake->ecdh_privkey,
|
||||||
|
ssl->handshake->premaster,
|
||||||
|
uecc_curve ) )
|
||||||
|
{
|
||||||
|
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
|
||||||
|
}
|
||||||
|
|
||||||
|
ssl->handshake->pmslen = NUM_ECC_BYTES;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED)
|
#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED)
|
||||||
if( mbedtls_ssl_suite_get_key_exchange( ciphersuite_info )
|
if( mbedtls_ssl_suite_get_key_exchange( ciphersuite_info )
|
||||||
== MBEDTLS_KEY_EXCHANGE_DHE_RSA )
|
== MBEDTLS_KEY_EXCHANGE_DHE_RSA )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue