fixup! Key derivation by small input steps: proof-of-concept
Simplify the logic inside a few case statements. This removes
unreachable break statements.
@@ -4384,8 +4384,8 @@ static psa_status_t psa_hkdf_input( psa_hkdf_generator_t *hkdf,
switch( step )
{
case PSA_KDF_STEP_SALT:
- if( hkdf->state == HKDF_STATE_INIT )
- {
+ if( hkdf->state != HKDF_STATE_INIT )
+ return( PSA_ERROR_BAD_STATE );
status = psa_hmac_setup_internal( &hkdf->hmac,
data, data_length,
hash_alg );
@@ -4393,10 +4393,6 @@ static psa_status_t psa_hkdf_input( psa_hkdf_generator_t *hkdf,
return( status );
hkdf->state = HKDF_STATE_STARTED;
return( PSA_SUCCESS );
- }
- else
- return( PSA_ERROR_BAD_STATE );
- break;
case PSA_KDF_STEP_SECRET:
/* If no salt was provided, use an empty salt. */
if( hkdf->state == HKDF_STATE_INIT )
@@ -4408,8 +4404,8 @@ static psa_status_t psa_hkdf_input( psa_hkdf_generator_t *hkdf,
return( status );
hkdf->state = HKDF_STATE_STARTED;
}
- if( hkdf->state == HKDF_STATE_STARTED )
- {
+ if( hkdf->state != HKDF_STATE_STARTED )
+ return( PSA_ERROR_BAD_STATE );
status = psa_hash_update( &hkdf->hmac.hash_ctx,
data, data_length );
if( status != PSA_SUCCESS )
@@ -4423,10 +4419,6 @@ static psa_status_t psa_hkdf_input( psa_hkdf_generator_t *hkdf,
hkdf->block_number = 0;
hkdf->state = HKDF_STATE_KEYED;
return( PSA_SUCCESS );
- }
- else
- return( PSA_ERROR_BAD_STATE );
- break;
case PSA_KDF_STEP_INFO:
if( hkdf->state == HKDF_STATE_OUTPUT )
return( PSA_ERROR_BAD_STATE );
@@ -4613,7 +4605,6 @@ static psa_status_t psa_key_agreement_raw_internal( psa_algorithm_t alg,
private_key->data.ecp,
shared_secret, shared_secret_size,
shared_secret_length ) );
- break;
#endif /* MBEDTLS_ECDH_C */
default:
(void) private_key;
