|
| 1 | +/* |
| 2 | + * Copyright (c) 2025 Nordic Semiconductor ASA |
| 3 | + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause |
| 4 | + */ |
| 5 | + |
| 6 | +#ifndef IRONSIDE_PSA_H |
| 7 | +#define IRONSIDE_PSA_H |
| 8 | + |
| 9 | +/** |
| 10 | + * @file ironside_psa.h |
| 11 | + * @brief IronSide PSA crypto driver interface |
| 12 | + * |
| 13 | + * This driver is to be implemented by IronSide firmware for these purposes: |
| 14 | + * |
| 15 | + * - Leverage Mbed TLS' built-in key concept to support additional keys, |
| 16 | + * with implementation-defined properties, in the PSA_KEY_ID_VENDOR range. |
| 17 | + * - Hijack the key creation functions of the PSA Crypto API to control |
| 18 | + * provisioning of such keys at different product life cycles. |
| 19 | + * - Capture the above functionality in its own driver, independent of other |
| 20 | + * crypto accelerators, for portability to future IronSide firmware variants. |
| 21 | + */ |
| 22 | + |
| 23 | +#include <psa/crypto.h> |
| 24 | + |
| 25 | +/* The following header must be provided externally and with these types: |
| 26 | + * - ironside_psa_pake_operation_t |
| 27 | + */ |
| 28 | +#include "ironside_psa_types.h" |
| 29 | + |
| 30 | +psa_status_t ironside_psa_get_key_slot(mbedtls_svc_key_id_t key_id, psa_key_lifetime_t *lifetime, |
| 31 | + psa_drv_slot_number_t *slot_number); |
| 32 | + |
| 33 | +psa_status_t ironside_psa_import_key(const psa_key_attributes_t *attributes, const uint8_t *data, |
| 34 | + size_t data_length, uint8_t *key_buffer, |
| 35 | + size_t key_buffer_size, size_t *key_buffer_length, |
| 36 | + size_t *bits); |
| 37 | + |
| 38 | +psa_status_t ironside_psa_get_key_buffer_size(const psa_key_attributes_t *attributes, |
| 39 | + size_t *key_buffer_size); |
| 40 | + |
| 41 | +psa_status_t ironside_psa_generate_key(const psa_key_attributes_t *attributes, uint8_t *key_buffer, |
| 42 | + size_t key_buffer_size, size_t *key_buffer_length); |
| 43 | + |
| 44 | +psa_status_t ironside_psa_get_builtin_key(psa_drv_slot_number_t slot_number, |
| 45 | + psa_key_attributes_t *attributes, uint8_t *key_buffer, |
| 46 | + size_t key_buffer_size, size_t *key_buffer_length); |
| 47 | + |
| 48 | +psa_status_t ironside_psa_copy_key(psa_key_attributes_t *attributes, const uint8_t *source_key, |
| 49 | + size_t source_key_length, uint8_t *target_key_buffer, |
| 50 | + size_t target_key_buffer_size, size_t *target_key_buffer_length); |
| 51 | + |
| 52 | +psa_status_t ironside_psa_derive_key(const psa_key_attributes_t *attributes, const uint8_t *input, |
| 53 | + size_t input_length, uint8_t *key_buffer, |
| 54 | + size_t key_buffer_size, size_t *key_buffer_length); |
| 55 | + |
| 56 | +psa_status_t ironside_psa_destroy_builtin_key(const psa_key_attributes_t *attributes); |
| 57 | + |
| 58 | +psa_status_t ironside_psa_key_agreement(const psa_key_attributes_t *attributes, |
| 59 | + const uint8_t *priv_key, size_t priv_key_size, |
| 60 | + psa_algorithm_t alg, const uint8_t *publ_key, |
| 61 | + size_t publ_key_size, uint8_t *output, size_t output_size, |
| 62 | + size_t *output_length); |
| 63 | + |
| 64 | +psa_status_t ironside_psa_key_encapsulate(const psa_key_attributes_t *attributes, |
| 65 | + const uint8_t *key, size_t key_length, |
| 66 | + psa_algorithm_t alg, |
| 67 | + const psa_key_attributes_t *output_attributes, |
| 68 | + uint8_t *output_key, size_t output_key_size, |
| 69 | + size_t *output_key_length, uint8_t *ciphertext, |
| 70 | + size_t ciphertext_size, size_t *ciphertext_length); |
| 71 | + |
| 72 | +psa_status_t ironside_psa_key_decapsulate(const psa_key_attributes_t *attributes, |
| 73 | + const uint8_t *key, size_t key_length, |
| 74 | + psa_algorithm_t alg, const uint8_t *ciphertext, |
| 75 | + size_t ciphertext_length, |
| 76 | + const psa_key_attributes_t *output_attributes, |
| 77 | + uint8_t *output_key, size_t output_key_size, |
| 78 | + size_t *output_key_length); |
| 79 | + |
| 80 | +psa_status_t ironside_psa_pake_setup(ironside_psa_pake_operation_t *operation, |
| 81 | + const psa_key_attributes_t *attributes, |
| 82 | + const uint8_t *password, size_t password_length, |
| 83 | + const psa_pake_cipher_suite_t *cipher_suite); |
| 84 | + |
| 85 | +psa_status_t ironside_psa_pake_set_role(ironside_psa_pake_operation_t *operation, |
| 86 | + psa_pake_role_t role); |
| 87 | + |
| 88 | +psa_status_t ironside_psa_pake_set_user(ironside_psa_pake_operation_t *operation, |
| 89 | + const uint8_t *user_id, size_t user_id_length); |
| 90 | + |
| 91 | +psa_status_t ironside_psa_pake_set_peer(ironside_psa_pake_operation_t *operation, |
| 92 | + const uint8_t *peer_id, size_t peer_id_length); |
| 93 | + |
| 94 | +psa_status_t ironside_psa_pake_set_context(ironside_psa_pake_operation_t *operation, |
| 95 | + const uint8_t *context, size_t context_length); |
| 96 | + |
| 97 | +psa_status_t ironside_psa_pake_output(ironside_psa_pake_operation_t *operation, |
| 98 | + psa_pake_step_t step, uint8_t *output, size_t output_size, |
| 99 | + size_t *output_length); |
| 100 | + |
| 101 | +psa_status_t ironside_psa_pake_input(ironside_psa_pake_operation_t *operation, psa_pake_step_t step, |
| 102 | + const uint8_t *input, size_t input_length); |
| 103 | + |
| 104 | +psa_status_t ironside_psa_pake_get_shared_key(ironside_psa_pake_operation_t *operation, |
| 105 | + const psa_key_attributes_t *attributes, |
| 106 | + uint8_t *key_buffer, size_t key_buffer_size, |
| 107 | + size_t *key_buffer_length); |
| 108 | + |
| 109 | +psa_status_t ironside_psa_pake_abort(ironside_psa_pake_operation_t *operation); |
| 110 | + |
| 111 | +#endif /* IRONSIDE_PSA_H */ |
0 commit comments