@@ -337,6 +337,39 @@ void test_use_other_partition_key_aead(void)
337
337
TEST_ASSERT_EQUAL (PSA_SUCCESS, test_partition_crypto_close_key (key_handle));
338
338
}
339
339
340
+ void test_use_other_partition_key_asymmetric_sign_verify (void )
341
+ {
342
+ static const psa_key_id_t key_id = 999 ;
343
+ static const psa_key_type_t key_type = PSA_KEY_TYPE_ECC_KEYPAIR (PSA_ECC_CURVE_SECP256R1);
344
+ static const psa_algorithm_t key_alg = PSA_ALG_ECDSA (PSA_ALG_SHA_256);
345
+ static const psa_key_usage_t key_usage = PSA_KEY_USAGE_SIGN | PSA_KEY_USAGE_VERIFY;
346
+ static const size_t key_bits = 256 ;
347
+ static const unsigned char input[] = " hello world!" ;
348
+ unsigned char signature[PSA_ECDSA_SIGNATURE_SIZE (key_bits)] = { 0 };
349
+ psa_key_handle_t key_handle = 0 ;
350
+ size_t len;
351
+
352
+ /* via test partition - create a key, set key policy, generate key material and close */
353
+ TEST_ASSERT_EQUAL (PSA_SUCCESS, create_and_generate_key_via_test_partition (key_id, key_type, key_alg, key_usage,
354
+ key_bits, &key_handle, 1 ));
355
+
356
+ /* via test partition - reopen the key created by the test partition */
357
+ key_handle = 0 ;
358
+ TEST_ASSERT_EQUAL (PSA_SUCCESS, test_partition_crypto_open_persistent_key (key_id, &key_handle));
359
+ TEST_ASSERT_NOT_EQUAL (0 , key_handle);
360
+
361
+ /* try to asymmetric sign using the key that was created by the test partition */
362
+ TEST_ASSERT_EQUAL (PSA_ERROR_INVALID_HANDLE, psa_asymmetric_sign (key_handle, key_alg, input, sizeof (input),
363
+ signature, sizeof (signature), &len));
364
+
365
+ /* try to asymmetric verify using the key that was created by the test partition */
366
+ TEST_ASSERT_EQUAL (PSA_ERROR_INVALID_HANDLE, psa_asymmetric_verify (key_handle, key_alg, input, sizeof (input),
367
+ signature, len));
368
+
369
+ /* via test partition - close the key created by the test partition */
370
+ TEST_ASSERT_EQUAL (PSA_SUCCESS, test_partition_crypto_close_key (key_handle));
371
+ }
372
+
340
373
utest::v1::status_t case_setup_handler (const Case *const source, const size_t index_of_case)
341
374
{
342
375
psa_status_t status = mbed_psa_reboot_and_request_new_security_state (PSA_LIFECYCLE_ASSEMBLY_AND_TEST);
@@ -382,6 +415,8 @@ Case cases[] = {
382
415
case_setup_handler, test_use_other_partition_key_cipher, case_teardown_handler),
383
416
Case (" use other partitions' key - aead" ,
384
417
case_setup_handler, test_use_other_partition_key_aead, case_teardown_handler),
418
+ Case (" use other partitions' key - asymmetric sign verify" ,
419
+ case_setup_handler, test_use_other_partition_key_asymmetric_sign_verify, case_teardown_handler),
385
420
};
386
421
387
422
Specification specification (test_setup, cases);
0 commit comments