2021-01-26 21:48:19 +01:00
|
|
|
/* BEGIN_HEADER */
|
|
|
|
|
|
|
|
#include "psa/crypto.h"
|
|
|
|
#include "test/psa_crypto_helpers.h"
|
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
#define INVALID_KEY_ID mbedtls_svc_key_id_make(0, 0xfedcba98)
|
2021-01-26 21:48:19 +01:00
|
|
|
|
|
|
|
/* END_HEADER */
|
|
|
|
|
|
|
|
/* BEGIN_DEPENDENCIES
|
|
|
|
* depends_on:MBEDTLS_PSA_CRYPTO_C
|
|
|
|
* END_DEPENDENCIES
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* BEGIN_CASE */
|
2023-01-11 14:50:10 +01:00
|
|
|
void import_not_supported(int key_type, data_t *key_material)
|
2021-01-26 21:48:19 +01:00
|
|
|
{
|
|
|
|
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
2021-02-16 18:28:56 +01:00
|
|
|
mbedtls_svc_key_id_t key_id = INVALID_KEY_ID;
|
2021-01-26 21:48:19 +01:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
PSA_ASSERT(psa_crypto_init());
|
|
|
|
psa_set_key_type(&attributes, key_type);
|
|
|
|
TEST_EQUAL(psa_import_key(&attributes,
|
|
|
|
key_material->x, key_material->len,
|
|
|
|
&key_id),
|
|
|
|
PSA_ERROR_NOT_SUPPORTED);
|
|
|
|
TEST_ASSERT(mbedtls_svc_key_id_equal(key_id, MBEDTLS_SVC_KEY_ID_INIT));
|
2021-01-26 21:48:19 +01:00
|
|
|
|
|
|
|
exit:
|
2023-01-11 14:50:10 +01:00
|
|
|
psa_destroy_key(key_id);
|
|
|
|
PSA_DONE();
|
2021-01-26 21:48:19 +01:00
|
|
|
}
|
|
|
|
/* END_CASE */
|
|
|
|
|
|
|
|
/* BEGIN_CASE */
|
2023-01-11 14:50:10 +01:00
|
|
|
void generate_not_supported(int key_type, int bits)
|
2021-01-26 21:48:19 +01:00
|
|
|
{
|
|
|
|
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
2021-02-16 18:28:56 +01:00
|
|
|
mbedtls_svc_key_id_t key_id = INVALID_KEY_ID;
|
2021-01-26 21:48:19 +01:00
|
|
|
|
2023-01-11 14:50:10 +01:00
|
|
|
PSA_ASSERT(psa_crypto_init());
|
|
|
|
psa_set_key_type(&attributes, key_type);
|
|
|
|
psa_set_key_bits(&attributes, bits);
|
|
|
|
TEST_EQUAL(psa_generate_key(&attributes, &key_id),
|
|
|
|
PSA_ERROR_NOT_SUPPORTED);
|
|
|
|
TEST_ASSERT(mbedtls_svc_key_id_equal(key_id, MBEDTLS_SVC_KEY_ID_INIT));
|
2021-01-26 21:48:19 +01:00
|
|
|
|
|
|
|
exit:
|
2023-01-11 14:50:10 +01:00
|
|
|
psa_destroy_key(key_id);
|
|
|
|
PSA_DONE();
|
2021-01-26 21:48:19 +01:00
|
|
|
}
|
|
|
|
/* END_CASE */
|