1 /* 2 * Copyright (c) 2024 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef PSA_CRYPTO_H 8 #define PSA_CRYPTO_H 9 10 #include "zephyr/types.h" 11 #include "psa/crypto_types.h" 12 #include "psa/crypto_values.h" 13 14 struct psa_client_key_attributes_s { 15 uint16_t type; 16 uint16_t bits; 17 uint32_t lifetime; 18 psa_key_id_t id; 19 uint32_t usage; 20 uint32_t alg; 21 }; 22 23 struct psa_key_attributes_s { 24 struct psa_client_key_attributes_s client; 25 }; 26 27 typedef struct psa_key_attributes_s psa_key_attributes_t; 28 29 psa_status_t psa_import_key(const psa_key_attributes_t *attributes, const uint8_t *data, 30 size_t data_length, mbedtls_svc_key_id_t *key); 31 32 psa_status_t psa_export_key(mbedtls_svc_key_id_t key, uint8_t *data, size_t data_size, 33 size_t *data_length); 34 35 psa_status_t psa_destroy_key(mbedtls_svc_key_id_t key); 36 void psa_set_key_id(psa_key_attributes_t *attributes, mbedtls_svc_key_id_t key); 37 void psa_set_key_bits(psa_key_attributes_t *attributes, size_t bits); 38 void psa_set_key_type(psa_key_attributes_t *attributes, psa_key_type_t type); 39 void psa_set_key_algorithm(psa_key_attributes_t *attributes, psa_algorithm_t alg); 40 void psa_set_key_lifetime(psa_key_attributes_t *attributes, psa_key_lifetime_t lifetime); 41 psa_status_t psa_destroy_key(mbedtls_svc_key_id_t key); 42 void psa_set_key_usage_flags(psa_key_attributes_t *attributes, psa_key_usage_t usage_flags); 43 44 #endif 45