Add verify call to max ops tests
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
parent
ba70ad4944
commit
f1743e2440
1 changed files with 27 additions and 4 deletions
|
@ -7484,8 +7484,13 @@ void interruptible_signverify_hash_maxops_tests(int key_type_arg,
|
|||
psa_key_type_t key_type = key_type_arg;
|
||||
psa_algorithm_t alg = alg_arg;
|
||||
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
||||
size_t key_bits;
|
||||
unsigned char *signature = NULL;
|
||||
size_t signature_size;
|
||||
psa_sign_hash_interruptible_operation_t sign_operation =
|
||||
psa_sign_hash_interruptible_operation_init();
|
||||
psa_verify_hash_interruptible_operation_t verify_operation =
|
||||
psa_verify_hash_interruptible_operation_init();
|
||||
|
||||
PSA_ASSERT(psa_crypto_init());
|
||||
|
||||
|
@ -7494,8 +7499,17 @@ void interruptible_signverify_hash_maxops_tests(int key_type_arg,
|
|||
psa_set_key_algorithm(&attributes, alg);
|
||||
psa_set_key_type(&attributes, key_type);
|
||||
|
||||
PSA_ASSERT(psa_import_key(&attributes, key_data->x, key_data->len,
|
||||
&key));
|
||||
PSA_ASSERT(psa_import_key(&attributes, key_data->x, key_data->len, &key));
|
||||
PSA_ASSERT(psa_get_key_attributes(key, &attributes));
|
||||
key_bits = psa_get_key_bits(&attributes);
|
||||
|
||||
/* Allocate a buffer which has the size advertised by the
|
||||
* library. */
|
||||
signature_size = PSA_SIGN_OUTPUT_SIZE(key_type, key_bits, alg);
|
||||
|
||||
TEST_ASSERT(signature_size != 0);
|
||||
TEST_LE_U(signature_size, PSA_SIGNATURE_MAX_SIZE);
|
||||
ASSERT_ALLOC(signature, signature_size);
|
||||
|
||||
/* Check that default max ops gets set if we don't set it. */
|
||||
PSA_ASSERT(psa_sign_hash_start(&sign_operation, key, alg,
|
||||
|
@ -7506,12 +7520,20 @@ void interruptible_signverify_hash_maxops_tests(int key_type_arg,
|
|||
|
||||
PSA_ASSERT(psa_sign_hash_abort(&sign_operation));
|
||||
|
||||
PSA_ASSERT(psa_verify_hash_start(&verify_operation, key, alg,
|
||||
input_data->x, input_data->len,
|
||||
signature, signature_size));
|
||||
|
||||
TEST_EQUAL(psa_interruptible_get_max_ops(),
|
||||
PSA_INTERRUPTIBLE_MAX_OPS_UNLIMITED);
|
||||
|
||||
PSA_ASSERT(psa_verify_hash_abort(&verify_operation));
|
||||
|
||||
/* Check that max ops gets set properly. */
|
||||
|
||||
psa_interruptible_set_max_ops(0xbeef);
|
||||
|
||||
TEST_EQUAL(psa_interruptible_get_max_ops(),
|
||||
0xbeef);
|
||||
TEST_EQUAL(psa_interruptible_get_max_ops(), 0xbeef);
|
||||
|
||||
exit:
|
||||
/*
|
||||
|
@ -7521,6 +7543,7 @@ exit:
|
|||
psa_reset_key_attributes(&attributes);
|
||||
|
||||
psa_destroy_key(key);
|
||||
mbedtls_free(signature);
|
||||
PSA_DONE();
|
||||
}
|
||||
/* END_CASE */
|
||||
|
|
Loading…
Reference in a new issue