mirror of
https://github.com/ARMmbed/mbedtls.git
synced 2025-06-15 00:45:50 +08:00
Adapt ec-jpake_setup test
Now when operation holds pointer to dynamically allocated buffer for password key we can't do copy of the operation object in test instead we need to re-initialize operation object after error. Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
parent
348410f709
commit
7c7954842b
@ -31,6 +31,29 @@
|
|||||||
#define ASSERT_OPERATION_IS_ACTIVE( operation ) TEST_ASSERT( operation.id != 0 )
|
#define ASSERT_OPERATION_IS_ACTIVE( operation ) TEST_ASSERT( operation.id != 0 )
|
||||||
#define ASSERT_OPERATION_IS_INACTIVE( operation ) TEST_ASSERT( operation.id == 0 )
|
#define ASSERT_OPERATION_IS_INACTIVE( operation ) TEST_ASSERT( operation.id == 0 )
|
||||||
|
|
||||||
|
#if defined(PSA_WANT_ALG_JPAKE)
|
||||||
|
void ecjpake_operation_setup( psa_pake_operation_t *operation,
|
||||||
|
psa_pake_cipher_suite_t *cipher_suite,
|
||||||
|
psa_pake_role_t role,
|
||||||
|
mbedtls_svc_key_id_t key,
|
||||||
|
size_t key_available )
|
||||||
|
{
|
||||||
|
*operation = psa_pake_operation_init();
|
||||||
|
|
||||||
|
TEST_EQUAL( psa_pake_setup( operation, cipher_suite ),
|
||||||
|
PSA_SUCCESS );
|
||||||
|
|
||||||
|
TEST_EQUAL( psa_pake_set_role( operation, role),
|
||||||
|
PSA_SUCCESS );
|
||||||
|
|
||||||
|
if( key_available )
|
||||||
|
TEST_EQUAL( psa_pake_set_password_key( operation, key ),
|
||||||
|
PSA_SUCCESS );
|
||||||
|
exit:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/** An invalid export length that will never be set by psa_export_key(). */
|
/** An invalid export length that will never be set by psa_export_key(). */
|
||||||
static const size_t INVALID_EXPORT_LENGTH = ~0U;
|
static const size_t INVALID_EXPORT_LENGTH = ~0U;
|
||||||
|
|
||||||
@ -8740,7 +8763,6 @@ void ecjpake_setup( int alg_arg, int key_type_pw_arg, int key_usage_pw_arg,
|
|||||||
{
|
{
|
||||||
psa_pake_cipher_suite_t cipher_suite = psa_pake_cipher_suite_init();
|
psa_pake_cipher_suite_t cipher_suite = psa_pake_cipher_suite_init();
|
||||||
psa_pake_operation_t operation = psa_pake_operation_init();
|
psa_pake_operation_t operation = psa_pake_operation_init();
|
||||||
psa_pake_operation_t op_copy = psa_pake_operation_init();
|
|
||||||
psa_algorithm_t alg = alg_arg;
|
psa_algorithm_t alg = alg_arg;
|
||||||
psa_pake_primitive_t primitive = primitive_arg;
|
psa_pake_primitive_t primitive = primitive_arg;
|
||||||
psa_key_type_t key_type_pw = key_type_pw_arg;
|
psa_key_type_t key_type_pw = key_type_pw_arg;
|
||||||
@ -8839,22 +8861,25 @@ void ecjpake_setup( int alg_arg, int key_type_pw_arg, int key_usage_pw_arg,
|
|||||||
if( input_first )
|
if( input_first )
|
||||||
{
|
{
|
||||||
/* Invalid parameters (input) */
|
/* Invalid parameters (input) */
|
||||||
op_copy = operation;
|
TEST_EQUAL( psa_pake_input( &operation, PSA_PAKE_STEP_ZK_PROOF,
|
||||||
TEST_EQUAL( psa_pake_input( &op_copy, PSA_PAKE_STEP_ZK_PROOF,
|
|
||||||
NULL, 0 ),
|
NULL, 0 ),
|
||||||
PSA_ERROR_INVALID_ARGUMENT );
|
PSA_ERROR_INVALID_ARGUMENT );
|
||||||
/* Invalid parameters (step) */
|
/* Invalid parameters (step) */
|
||||||
op_copy = operation;
|
ecjpake_operation_setup( &operation, &cipher_suite, role,
|
||||||
TEST_EQUAL( psa_pake_input( &op_copy, PSA_PAKE_STEP_ZK_PROOF + 10,
|
key, pw_data->len );
|
||||||
|
TEST_EQUAL( psa_pake_input( &operation, PSA_PAKE_STEP_ZK_PROOF + 10,
|
||||||
output_buffer, size_zk_proof ),
|
output_buffer, size_zk_proof ),
|
||||||
PSA_ERROR_INVALID_ARGUMENT );
|
PSA_ERROR_INVALID_ARGUMENT );
|
||||||
/* Invalid first step */
|
/* Invalid first step */
|
||||||
op_copy = operation;
|
ecjpake_operation_setup( &operation, &cipher_suite, role,
|
||||||
TEST_EQUAL( psa_pake_input( &op_copy, PSA_PAKE_STEP_ZK_PROOF,
|
key, pw_data->len );
|
||||||
|
TEST_EQUAL( psa_pake_input( &operation, PSA_PAKE_STEP_ZK_PROOF,
|
||||||
output_buffer, size_zk_proof ),
|
output_buffer, size_zk_proof ),
|
||||||
PSA_ERROR_BAD_STATE );
|
PSA_ERROR_BAD_STATE );
|
||||||
|
|
||||||
/* Possibly valid */
|
/* Possibly valid */
|
||||||
|
ecjpake_operation_setup( &operation, &cipher_suite, role,
|
||||||
|
key, pw_data->len );
|
||||||
TEST_EQUAL( psa_pake_input( &operation, PSA_PAKE_STEP_KEY_SHARE,
|
TEST_EQUAL( psa_pake_input( &operation, PSA_PAKE_STEP_KEY_SHARE,
|
||||||
output_buffer, size_key_share ),
|
output_buffer, size_key_share ),
|
||||||
expected_status_input_output);
|
expected_status_input_output);
|
||||||
@ -8875,22 +8900,25 @@ void ecjpake_setup( int alg_arg, int key_type_pw_arg, int key_usage_pw_arg,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Invalid parameters (output) */
|
/* Invalid parameters (output) */
|
||||||
op_copy = operation;
|
TEST_EQUAL( psa_pake_output( &operation, PSA_PAKE_STEP_ZK_PROOF,
|
||||||
TEST_EQUAL( psa_pake_output( &op_copy, PSA_PAKE_STEP_ZK_PROOF,
|
|
||||||
NULL, 0, NULL ),
|
NULL, 0, NULL ),
|
||||||
PSA_ERROR_INVALID_ARGUMENT );
|
PSA_ERROR_INVALID_ARGUMENT );
|
||||||
op_copy = operation;
|
|
||||||
/* Invalid parameters (step) */
|
/* Invalid parameters (step) */
|
||||||
TEST_EQUAL( psa_pake_output( &op_copy, PSA_PAKE_STEP_ZK_PROOF + 10,
|
ecjpake_operation_setup( &operation, &cipher_suite, role,
|
||||||
|
key, pw_data->len );
|
||||||
|
TEST_EQUAL( psa_pake_output( &operation, PSA_PAKE_STEP_ZK_PROOF + 10,
|
||||||
output_buffer, buf_size, &output_len ),
|
output_buffer, buf_size, &output_len ),
|
||||||
PSA_ERROR_INVALID_ARGUMENT );
|
PSA_ERROR_INVALID_ARGUMENT );
|
||||||
/* Invalid first step */
|
/* Invalid first step */
|
||||||
op_copy = operation;
|
ecjpake_operation_setup( &operation, &cipher_suite, role,
|
||||||
TEST_EQUAL( psa_pake_output( &op_copy, PSA_PAKE_STEP_ZK_PROOF,
|
key, pw_data->len );
|
||||||
|
TEST_EQUAL( psa_pake_output( &operation, PSA_PAKE_STEP_ZK_PROOF,
|
||||||
output_buffer, buf_size, &output_len ),
|
output_buffer, buf_size, &output_len ),
|
||||||
PSA_ERROR_BAD_STATE );
|
PSA_ERROR_BAD_STATE );
|
||||||
|
|
||||||
/* Possibly valid */
|
/* Possibly valid */
|
||||||
|
ecjpake_operation_setup( &operation, &cipher_suite, role,
|
||||||
|
key, pw_data->len );
|
||||||
TEST_EQUAL( psa_pake_output( &operation, PSA_PAKE_STEP_KEY_SHARE,
|
TEST_EQUAL( psa_pake_output( &operation, PSA_PAKE_STEP_KEY_SHARE,
|
||||||
output_buffer, buf_size, &output_len ),
|
output_buffer, buf_size, &output_len ),
|
||||||
expected_status_input_output );
|
expected_status_input_output );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user