Check for PSA_ALG_ECJPAKE alg for the ECJPAKE builtin implementation
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
This commit is contained in:
parent
df598abbd3
commit
4efd7a463d
1 changed files with 316 additions and 302 deletions
|
@ -131,8 +131,9 @@ psa_status_t psa_pake_setup( psa_pake_operation_t *operation,
|
|||
}
|
||||
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_ECJPAKE)
|
||||
if( cipher_suite->algorithm != PSA_ALG_JPAKE ||
|
||||
cipher_suite->type != PSA_PAKE_PRIMITIVE_TYPE_ECC ||
|
||||
if( cipher_suite->algorithm == PSA_ALG_JPAKE )
|
||||
{
|
||||
if( cipher_suite->type != PSA_PAKE_PRIMITIVE_TYPE_ECC ||
|
||||
cipher_suite->family != PSA_ECC_FAMILY_SECP_R1 ||
|
||||
cipher_suite->bits != 256 ||
|
||||
cipher_suite->hash != PSA_ALG_SHA_256 )
|
||||
|
@ -154,9 +155,10 @@ psa_status_t psa_pake_setup( psa_pake_operation_t *operation,
|
|||
operation->buffer_offset = 0;
|
||||
|
||||
return( PSA_SUCCESS );
|
||||
#else
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t psa_pake_set_password_key( psa_pake_operation_t *operation,
|
||||
|
@ -327,6 +329,8 @@ psa_status_t psa_pake_output( psa_pake_operation_t *operation,
|
|||
return( PSA_ERROR_INVALID_ARGUMENT );
|
||||
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_ECJPAKE)
|
||||
if( operation->alg == PSA_ALG_JPAKE )
|
||||
{
|
||||
if( operation->state == PSA_PAKE_STATE_SETUP ) {
|
||||
status = psa_pake_ecjpake_setup( operation );
|
||||
if( status != PSA_SUCCESS )
|
||||
|
@ -480,9 +484,10 @@ psa_status_t psa_pake_output( psa_pake_operation_t *operation,
|
|||
operation->sequence++;
|
||||
|
||||
return( PSA_SUCCESS );
|
||||
#else
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t psa_pake_input( psa_pake_operation_t *operation,
|
||||
|
@ -504,6 +509,8 @@ psa_status_t psa_pake_input( psa_pake_operation_t *operation,
|
|||
return( PSA_ERROR_INVALID_ARGUMENT );
|
||||
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_ECJPAKE)
|
||||
if( operation->alg == PSA_ALG_JPAKE )
|
||||
{
|
||||
if( operation->state == PSA_PAKE_STATE_SETUP ) {
|
||||
status = psa_pake_ecjpake_setup( operation );
|
||||
if( status != PSA_SUCCESS )
|
||||
|
@ -633,9 +640,10 @@ psa_status_t psa_pake_input( psa_pake_operation_t *operation,
|
|||
operation->sequence++;
|
||||
|
||||
return( PSA_SUCCESS );
|
||||
#else
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t psa_pake_get_implicit_key(psa_pake_operation_t *operation,
|
||||
|
@ -651,6 +659,8 @@ psa_status_t psa_pake_get_implicit_key(psa_pake_operation_t *operation,
|
|||
return( PSA_ERROR_BAD_STATE );
|
||||
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_ECJPAKE)
|
||||
if( operation->alg == PSA_ALG_JPAKE )
|
||||
{
|
||||
ret = mbedtls_ecjpake_derive_secret( &operation->ctx.ecjpake,
|
||||
operation->buffer,
|
||||
PSA_PAKE_BUFFER_SIZE,
|
||||
|
@ -673,9 +683,10 @@ psa_status_t psa_pake_get_implicit_key(psa_pake_operation_t *operation,
|
|||
psa_pake_abort( operation );
|
||||
|
||||
return( status );
|
||||
#else
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return( PSA_ERROR_NOT_SUPPORTED );
|
||||
}
|
||||
|
||||
psa_status_t psa_pake_abort(psa_pake_operation_t * operation)
|
||||
|
@ -690,6 +701,8 @@ psa_status_t psa_pake_abort(psa_pake_operation_t * operation)
|
|||
operation->sequence = 0;
|
||||
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_ECJPAKE)
|
||||
if( operation->alg == PSA_ALG_JPAKE )
|
||||
{
|
||||
operation->input_step = 0;
|
||||
operation->output_step = 0;
|
||||
operation->password = MBEDTLS_SVC_KEY_ID_INIT;
|
||||
|
@ -699,6 +712,7 @@ psa_status_t psa_pake_abort(psa_pake_operation_t * operation)
|
|||
operation->buffer_length = 0;
|
||||
operation->buffer_offset = 0;
|
||||
mbedtls_ecjpake_free( &operation->ctx.ecjpake );
|
||||
}
|
||||
#endif
|
||||
|
||||
return( PSA_SUCCESS );
|
||||
|
|
Loading…
Reference in a new issue