fixup! Key derivation by small input steps: proof-of-concept
Simplify the logic inside a few case statements. This removes unreachable break statements.
This commit is contained in:
parent
22c51517fb
commit
2b522db26d
@ -4384,8 +4384,8 @@ static psa_status_t psa_hkdf_input( psa_hkdf_generator_t *hkdf,
|
|||||||
switch( step )
|
switch( step )
|
||||||
{
|
{
|
||||||
case PSA_KDF_STEP_SALT:
|
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,
|
status = psa_hmac_setup_internal( &hkdf->hmac,
|
||||||
data, data_length,
|
data, data_length,
|
||||||
hash_alg );
|
hash_alg );
|
||||||
@ -4393,10 +4393,6 @@ static psa_status_t psa_hkdf_input( psa_hkdf_generator_t *hkdf,
|
|||||||
return( status );
|
return( status );
|
||||||
hkdf->state = HKDF_STATE_STARTED;
|
hkdf->state = HKDF_STATE_STARTED;
|
||||||
return( PSA_SUCCESS );
|
return( PSA_SUCCESS );
|
||||||
}
|
|
||||||
else
|
|
||||||
return( PSA_ERROR_BAD_STATE );
|
|
||||||
break;
|
|
||||||
case PSA_KDF_STEP_SECRET:
|
case PSA_KDF_STEP_SECRET:
|
||||||
/* If no salt was provided, use an empty salt. */
|
/* If no salt was provided, use an empty salt. */
|
||||||
if( hkdf->state == HKDF_STATE_INIT )
|
if( hkdf->state == HKDF_STATE_INIT )
|
||||||
@ -4408,8 +4404,8 @@ static psa_status_t psa_hkdf_input( psa_hkdf_generator_t *hkdf,
|
|||||||
return( status );
|
return( status );
|
||||||
hkdf->state = HKDF_STATE_STARTED;
|
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,
|
status = psa_hash_update( &hkdf->hmac.hash_ctx,
|
||||||
data, data_length );
|
data, data_length );
|
||||||
if( status != PSA_SUCCESS )
|
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->block_number = 0;
|
||||||
hkdf->state = HKDF_STATE_KEYED;
|
hkdf->state = HKDF_STATE_KEYED;
|
||||||
return( PSA_SUCCESS );
|
return( PSA_SUCCESS );
|
||||||
}
|
|
||||||
else
|
|
||||||
return( PSA_ERROR_BAD_STATE );
|
|
||||||
break;
|
|
||||||
case PSA_KDF_STEP_INFO:
|
case PSA_KDF_STEP_INFO:
|
||||||
if( hkdf->state == HKDF_STATE_OUTPUT )
|
if( hkdf->state == HKDF_STATE_OUTPUT )
|
||||||
return( PSA_ERROR_BAD_STATE );
|
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,
|
private_key->data.ecp,
|
||||||
shared_secret, shared_secret_size,
|
shared_secret, shared_secret_size,
|
||||||
shared_secret_length ) );
|
shared_secret_length ) );
|
||||||
break;
|
|
||||||
#endif /* MBEDTLS_ECDH_C */
|
#endif /* MBEDTLS_ECDH_C */
|
||||||
default:
|
default:
|
||||||
(void) private_key;
|
(void) private_key;
|
||||||
|
Loading…
Reference in New Issue
Block a user