Return and propagate UECC_FAULT_DETECTED
This commit first changes the return convention of EccPoint_mult_safer() so that it properly reports when faults are detected. Then all functions that call it need to be changed to (1) follow the same return convention and (2) properly propagate UECC_FAULT_DETECTED when it occurs. Here's the reverse call graph from EccPoint_mult_safer() to the rest of the library (where return values are translated to the MBEDTLS_ERR_ space) and test functions (where expected return values are asserted explicitly). EccPoint_mult_safer() EccPoint_compute_public_key() uECC_compute_public_key() pkparse.c tests/suites/test_suite_pkparse.function uECC_make_key_with_d() uECC_make_key() ssl_cli.c ssl_srv.c tests/suites/test_suite_pk.function tests/suites/test_suite_tinycrypt.function uECC_shared_secret() ssl_tls.c tests/suites/test_suite_tinycrypt.function uECC_sign_with_k() uECC_sign() pk.c tests/suites/test_suite_tinycrypt.function Note: in uECC_sign_with_k() a test for uECC_vli_isZero(p) is suppressed because it is redundant with a more thorough test (point validity) done at the end of EccPoint_mult_safer(). This redundancy was introduced in a previous commit but not noticed earlier.
This commit is contained in:
parent
4d6186beb0
commit
9d6a535ba1
14 changed files with 112 additions and 96 deletions
|
@ -3568,7 +3568,6 @@ static int ssl_out_client_key_exchange_write( mbedtls_ssl_context *ssl,
|
|||
|
||||
{
|
||||
((void) n);
|
||||
((void) ret);
|
||||
|
||||
if( (size_t)( end - p ) < 2 * NUM_ECC_BYTES + 2 )
|
||||
return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL );
|
||||
|
@ -3576,10 +3575,11 @@ static int ssl_out_client_key_exchange_write( mbedtls_ssl_context *ssl,
|
|||
*p++ = 2 * NUM_ECC_BYTES + 1;
|
||||
*p++ = 0x04; /* uncompressed point presentation */
|
||||
|
||||
if( !uECC_make_key( p, ssl->handshake->ecdh_privkey ) )
|
||||
{
|
||||
ret = uECC_make_key( p, ssl->handshake->ecdh_privkey );
|
||||
if( ret == UECC_FAULT_DETECTED )
|
||||
return( MBEDTLS_ERR_PLATFORM_FAULT_DETECTED );
|
||||
if( ret != UECC_SUCCESS )
|
||||
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
|
||||
}
|
||||
p += 2 * NUM_ECC_BYTES;
|
||||
}
|
||||
else
|
||||
|
@ -3717,7 +3717,6 @@ static int ssl_out_client_key_exchange_write( mbedtls_ssl_context *ssl,
|
|||
{
|
||||
#if defined(MBEDTLS_USE_TINYCRYPT)
|
||||
((void) n);
|
||||
((void) ret);
|
||||
|
||||
if( (size_t)( end - p ) < 2 * NUM_ECC_BYTES + 2 )
|
||||
return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL );
|
||||
|
@ -3725,10 +3724,11 @@ static int ssl_out_client_key_exchange_write( mbedtls_ssl_context *ssl,
|
|||
*p++ = 2 * NUM_ECC_BYTES + 1;
|
||||
*p++ = 0x04; /* uncompressed point presentation */
|
||||
|
||||
if( !uECC_make_key( p, ssl->handshake->ecdh_privkey ) )
|
||||
{
|
||||
ret = uECC_make_key( p, ssl->handshake->ecdh_privkey );
|
||||
if( ret == UECC_FAULT_DETECTED )
|
||||
return( MBEDTLS_ERR_PLATFORM_FAULT_DETECTED );
|
||||
if( ret != UECC_SUCCESS )
|
||||
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
|
||||
}
|
||||
p += 2 * NUM_ECC_BYTES;
|
||||
#else /* MBEDTLS_USE_TINYCRYPT */
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue