Skip to content

Commit 44985ef

Browse files
57300rlubos
authored andcommitted
nrf_security: Add IronSide PSA crypto driver interface
Define the functions that will be used to implement a transparent driver for platform keys in IronSide SE. This new driver will be used alongside the CRACEN driver. Ref: NCSDK-35399 Signed-off-by: Grzegorz Swiderski <[email protected]>
1 parent ff5ff4a commit 44985ef

File tree

7 files changed

+149
-0
lines changed

7 files changed

+149
-0
lines changed

subsys/nrf_security/cmake/psa_crypto_config.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ kconfig_check_and_set_base_to_one(PSA_NEED_CRACEN_TRNG_DRIVER)
498498

499499
# Nordic specific
500500
kconfig_check_and_set_base_to_one(PSA_CRYPTO_DRIVER_ALG_PRNG_TEST)
501+
kconfig_check_and_set_base_to_one(PSA_CRYPTO_DRIVER_IRONSIDE)
501502

502503
# PSA and Drivers
503504
kconfig_check_and_set_base_to_one(MBEDTLS_PSA_CRYPTO_STORAGE_C)

subsys/nrf_security/configs/psa_crypto_config.h.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@
490490

491491
/* Nordic specific */
492492
#cmakedefine PSA_CRYPTO_DRIVER_ALG_PRNG_TEST @PSA_CRYPTO_DRIVER_ALG_PRNG_TEST@
493+
#cmakedefine PSA_CRYPTO_DRIVER_IRONSIDE @PSA_CRYPTO_DRIVER_IRONSIDE@
493494

494495
/* PSA and drivers */
495496
#cmakedefine MBEDTLS_PSA_CRYPTO_C

subsys/nrf_security/include/psa/crypto_driver_contexts_key_derivation.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
#include "cracen_psa_primitives.h"
2929
#endif
3030

31+
#if defined(PSA_CRYPTO_DRIVER_IRONSIDE)
32+
#include "ironside_psa_types.h"
33+
#endif
34+
3135
/*
3236
* Define the context to be used for an operation that is executed through the
3337
* PSA Driver wrapper layer as the union of all possible drivers' contexts.
@@ -56,6 +60,9 @@ typedef union {
5660
#ifdef PSA_NEED_CRACEN_PAKE_DRIVER
5761
cracen_pake_operation_t cracen_pake_ctx;
5862
#endif
63+
#ifdef PSA_CRYPTO_DRIVER_IRONSIDE
64+
ironside_psa_pake_operation_t ironside_pake_ctx;
65+
#endif
5966
} psa_driver_pake_context_t;
6067

6168
typedef union {

subsys/nrf_security/src/drivers/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ if(CONFIG_MBEDTLS_PSA_CRYPTO_C)
2424
add_subdirectory(nrf_oberon)
2525
endif()
2626

27+
if(CONFIG_PSA_CRYPTO_DRIVER_IRONSIDE)
28+
add_subdirectory(ironside)
29+
endif()
30+
2731
add_subdirectory(zephyr)
2832
endif()
2933

subsys/nrf_security/src/drivers/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ config PSA_CRYPTO_DRIVER_CRACEN
3636
help
3737
PSA crypto driver for the CRACEN HW peripheral.
3838

39+
config PSA_CRYPTO_DRIVER_IRONSIDE
40+
bool
41+
help
42+
Internal option selected by IronSide firmware to enable
43+
the IronSide PSA crypto driver.
44+
3945
menu "Choose DRBG algorithm"
4046
config PSA_WANT_ALG_CTR_DRBG
4147
prompt "CTR_DRBG"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright (c) 2025 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
3+
4+
# Driver sources are expected to be added externally
5+
add_library(ironside_psa_driver STATIC)
6+
7+
target_include_directories(psa_crypto_library_config
8+
INTERFACE
9+
${CMAKE_CURRENT_LIST_DIR}
10+
$<TARGET_PROPERTY:ironside_psa_driver,INTERFACE_INCLUDE_DIRECTORIES>
11+
)
12+
13+
# Link psa_core with this driver
14+
target_link_libraries(psa_core
15+
PRIVATE
16+
ironside_psa_driver
17+
)
18+
19+
nrf_security_add_zephyr_options_library(ironside_psa_driver)
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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

Comments
 (0)