Skip to content

Commit 0590959

Browse files
degjorvanordicjm
authored andcommitted
nrf_security: cracen_sw: Add support for aead with AES-CCM
Add support for AES-CCM using ECB primitives when using cracen_need_multipart_workarounds or cracen_need_ctr_size_workarounds Add AEAD to cracen_sw with AES-CCM support. Signed-off-by: Dag Erik Gjørvad <[email protected]>
1 parent 9b27274 commit 0590959

File tree

11 files changed

+1823
-82
lines changed

11 files changed

+1823
-82
lines changed

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ Developing with custom boards
113113
Security
114114
========
115115

116-
|no_changes_yet_note|
116+
* Added:
117+
118+
* Support for AES-CCM AEAD using CRACEN for the :zephyr:board:`nrf54lm20dk`.
117119

118120
Protocols
119121
=========
@@ -246,7 +248,9 @@ Cellular samples
246248
Cryptography samples
247249
--------------------
248250

249-
|no_changes_yet_note|
251+
* :ref:`crypto_aes_ccm` sample:
252+
253+
* Added support for the ``nrf54lm20dk/nrf54lm20a/cpuapp`` board target.
250254

251255
Debug samples
252256
-------------

doc/nrf/security/crypto/crypto_supported_features.rst

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4188,8 +4188,8 @@ The options are grouped by Series and drivers available for the device Series, a
41884188
- Supported
41894189
- Supported
41904190
- Supported
4191-
- Experimental (with exceptions, see note)
4192-
- Experimental (with exceptions, see note)
4191+
- Experimental
4192+
- Experimental
41934193
* - GCM
41944194
- :kconfig:option:`CONFIG_PSA_WANT_ALG_GCM`
41954195
- Supported
@@ -4219,24 +4219,11 @@ The options are grouped by Series and drivers available for the device Series, a
42194219

42204220
* 192-bit keys are not supported.
42214221
See also :ref:`ug_crypto_supported_features_aes_key_sizes`.
4222-
* CCM cipher mode:
4223-
4224-
* Multi-part encrypt and decrypt APIs are not supported.
4225-
* A maximum of 1 MB of plaintext or ciphertext is supported.
42264222

42274223
* GCM and ChaCha20-Poly1305 cipher modes:
42284224

42294225
* Multi-part encrypt and decrypt APIs are not supported.
42304226

4231-
* The following limitations apply for nRF54LV10A when using the CRACEN driver:
4232-
4233-
* 192-bit keys are not supported.
4234-
See also :ref:`ug_crypto_supported_features_aes_key_sizes`.
4235-
4236-
* CCM cipher mode:
4237-
4238-
* A maximum of 1 MB of plaintext or ciphertext is supported.
4239-
42404227
.. tab:: nrf_oberon
42414228

42424229
.. list-table:: AEAD algorithm support (nrf_oberon driver) - nRF54L Series

subsys/nrf_security/src/drivers/cracen/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ set(cracen_driver_sources)
1111
include(sxsymcrypt/sxsymcrypt.cmake)
1212
include(silexpk/silexpk.cmake)
1313
include(cracenpsa/cracenpsa.cmake)
14-
if(CONFIG_PSA_NEED_CRACEN_CTR_SIZE_WORKAROUNDS)
14+
if((CONFIG_PSA_NEED_CRACEN_CTR_SIZE_WORKAROUNDS AND
15+
(CONFIG_PSA_NEED_CRACEN_CTR_AES OR CONFIG_PSA_NEED_CRACEN_CCM_AES)) OR
16+
CONFIG_PSA_NEED_CRACEN_MULTIPART_WORKAROUNDS)
1517
include(cracen_sw/cracen_sw.cmake)
1618
endif()
1719

subsys/nrf_security/src/drivers/cracen/cracen_sw/cracen_sw.cmake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,17 @@ if(CONFIG_PSA_NEED_CRACEN_MULTIPART_WORKAROUNDS AND
4545
${CMAKE_CURRENT_LIST_DIR}/src/cracen_sw_aes_cbc.c
4646
)
4747
endif()
48+
49+
if(CONFIG_PSA_NEED_CRACEN_CTR_SIZE_WORKAROUNDS AND CONFIG_PSA_NEED_CRACEN_CCM_AES)
50+
list(APPEND cracen_driver_sources
51+
${CMAKE_CURRENT_LIST_DIR}/src/cracen_sw_aes_ccm.c
52+
)
53+
endif()
54+
55+
if(CONFIG_PSA_NEED_CRACEN_MULTIPART_WORKAROUNDS)
56+
if(CONFIG_PSA_NEED_CRACEN_CCM_AES OR CONFIG_PSA_NEED_CRACEN_GCM_AES OR CONFIG_PSA_NEED_CRACEN_CHACHA20_POLY1305)
57+
list(APPEND cracen_driver_sources
58+
${CMAKE_CURRENT_LIST_DIR}/src/cracen_sw_aead.c
59+
)
60+
endif()
61+
endif()
Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/**
8+
* @file cracen_sw_aead.h
9+
*
10+
* @defgroup cracen_sw_aead Software AEAD dispatcher
11+
* @{
12+
* @brief Dispatcher layer for the software AEAD implementations.
13+
*
14+
* This module provides a common interface that dispatches to specific
15+
* software AEAD implementations (such as AES-CCM) as a workaround for
16+
* hardware limitations with multipart operations.
17+
*/
18+
19+
#ifndef CRACEN_SW_AEAD_H
20+
#define CRACEN_SW_AEAD_H
21+
22+
#include <psa/crypto.h>
23+
#include <stdbool.h>
24+
#include <stdint.h>
25+
#include "cracen_psa_primitives.h"
26+
27+
/**
28+
* @brief Set up the software AEAD encryption operation.
29+
*
30+
* @param[in,out] operation Pointer to the AEAD operation structure.
31+
* @param[in] attributes Key attributes.
32+
* @param[in] key_buffer Key material.
33+
* @param[in] key_buffer_size Size of the key material.
34+
* @param[in] alg AEAD algorithm to use.
35+
*
36+
* @retval PSA_SUCCESS Operation setup successfully.
37+
* @retval PSA_ERROR_NOT_SUPPORTED Unsupported algorithm.
38+
* @retval PSA_ERROR_INVALID_ARGUMENT Invalid key size.
39+
*/
40+
psa_status_t cracen_aead_encrypt_setup(cracen_aead_operation_t *operation,
41+
const psa_key_attributes_t *attributes,
42+
const uint8_t *key_buffer, size_t key_buffer_size,
43+
psa_algorithm_t alg);
44+
45+
/**
46+
* @brief Set up the software AEAD decryption operation.
47+
*
48+
* @param[in,out] operation Pointer to the AEAD operation structure.
49+
* @param[in] attributes Key attributes.
50+
* @param[in] key_buffer Key material.
51+
* @param[in] key_buffer_size Size of the key material.
52+
* @param[in] alg AEAD algorithm to use.
53+
*
54+
* @retval PSA_SUCCESS Operation setup successfully.
55+
* @retval PSA_ERROR_NOT_SUPPORTED Unsupported algorithm.
56+
* @retval PSA_ERROR_INVALID_ARGUMENT Invalid key size.
57+
*/
58+
psa_status_t cracen_aead_decrypt_setup(cracen_aead_operation_t *operation,
59+
const psa_key_attributes_t *attributes,
60+
const uint8_t *key_buffer, size_t key_buffer_size,
61+
psa_algorithm_t alg);
62+
63+
/**
64+
* @brief Set nonce for the software AEAD operation.
65+
*
66+
* @param[in,out] operation Pointer to the AEAD operation structure.
67+
* @param[in] nonce Nonce/IV value.
68+
* @param[in] nonce_length Length of the nonce.
69+
*
70+
* @retval PSA_SUCCESS Nonce set successfully.
71+
* @retval PSA_ERROR_NOT_SUPPORTED Unsupported algorithm.
72+
* @retval PSA_ERROR_INVALID_ARGUMENT Invalid nonce length.
73+
*/
74+
psa_status_t cracen_aead_set_nonce(cracen_aead_operation_t *operation, const uint8_t *nonce,
75+
size_t nonce_length);
76+
77+
/**
78+
* @brief Set lengths for the software AEAD operation.
79+
*
80+
* Some AEAD algorithms (such as CCM) require lengths to be known up-front.
81+
*
82+
* @param[in,out] operation Pointer to the AEAD operation structure.
83+
* @param[in] ad_length Length of additional data.
84+
* @param[in] plaintext_length Length of plaintext/ciphertext.
85+
*
86+
* @retval PSA_SUCCESS Lengths set successfully.
87+
* @retval PSA_ERROR_NOT_SUPPORTED Unsupported algorithm.
88+
*/
89+
psa_status_t cracen_aead_set_lengths(cracen_aead_operation_t *operation, size_t ad_length,
90+
size_t plaintext_length);
91+
92+
/**
93+
* @brief Update the software AEAD operation with additional data.
94+
*
95+
* @param[in,out] operation Pointer to the AEAD operation structure.
96+
* @param[in] input Additional data.
97+
* @param[in] input_length Length of additional data.
98+
*
99+
* @retval PSA_SUCCESS Additional data processed successfully.
100+
* @retval PSA_ERROR_NOT_SUPPORTED Unsupported algorithm.
101+
* @retval PSA_ERROR_BAD_STATE AD already finalized or operation not initialized.
102+
*/
103+
psa_status_t cracen_aead_update_ad(cracen_aead_operation_t *operation, const uint8_t *input,
104+
size_t input_length);
105+
106+
/**
107+
* @brief Update the software AEAD operation with plaintext/ciphertext.
108+
*
109+
* @param[in,out] operation Pointer to the AEAD operation structure.
110+
* @param[in] input Input data (plaintext for encrypt, ciphertext for decrypt).
111+
* @param[in] input_length Length of input data.
112+
* @param[out] output Output buffer.
113+
* @param[in] output_size Size of output buffer.
114+
* @param[out] output_length Pointer to store actual output length.
115+
*
116+
* @retval PSA_SUCCESS Data processed successfully.
117+
* @retval PSA_ERROR_NOT_SUPPORTED Unsupported algorithm.
118+
* @retval PSA_ERROR_BUFFER_TOO_SMALL Output buffer too small.
119+
* @retval PSA_ERROR_BAD_STATE Operation not initialized.
120+
*/
121+
psa_status_t cracen_aead_update(cracen_aead_operation_t *operation, const uint8_t *input,
122+
size_t input_length, uint8_t *output, size_t output_size,
123+
size_t *output_length);
124+
125+
/**
126+
* @brief Finish the software AEAD encryption and generate the tag.
127+
*
128+
* @param[in,out] operation Pointer to the AEAD operation structure.
129+
* @param[out] ciphertext Final ciphertext output buffer.
130+
* @param[in] ciphertext_size Size of ciphertext buffer.
131+
* @param[out] ciphertext_length Pointer to store actual ciphertext length.
132+
* @param[out] tag Tag output buffer.
133+
* @param[in] tag_size Size of tag buffer.
134+
* @param[out] tag_length Pointer to store actual tag length.
135+
*
136+
* @retval PSA_SUCCESS Encryption finished successfully; tag generated.
137+
* @retval PSA_ERROR_NOT_SUPPORTED Unsupported algorithm.
138+
* @retval PSA_ERROR_BUFFER_TOO_SMALL Tag buffer too small.
139+
* @retval PSA_ERROR_BAD_STATE Operation not initialized.
140+
*/
141+
psa_status_t cracen_aead_finish(cracen_aead_operation_t *operation, uint8_t *ciphertext,
142+
size_t ciphertext_size, size_t *ciphertext_length, uint8_t *tag,
143+
size_t tag_size, size_t *tag_length);
144+
145+
/**
146+
* @brief Finish the software AEAD decryption and verify the tag.
147+
*
148+
* @param[in,out] operation Pointer to the AEAD operation structure.
149+
* @param[out] plaintext Final plaintext output buffer.
150+
* @param[in] plaintext_size Size of plaintext buffer.
151+
* @param[out] plaintext_length Pointer to store actual plaintext length.
152+
* @param[in] tag Tag to verify.
153+
* @param[in] tag_length Length of the tag.
154+
*
155+
* @retval PSA_SUCCESS Decryption finished successfully; tag verified.
156+
* @retval PSA_ERROR_NOT_SUPPORTED Unsupported algorithm.
157+
* @retval PSA_ERROR_INVALID_SIGNATURE Tag verification failed.
158+
* @retval PSA_ERROR_BAD_STATE Operation not initialized.
159+
*/
160+
psa_status_t cracen_aead_verify(cracen_aead_operation_t *operation, uint8_t *plaintext,
161+
size_t plaintext_size, size_t *plaintext_length, const uint8_t *tag,
162+
size_t tag_length);
163+
164+
/**
165+
* @brief Abort the software AEAD operation.
166+
*
167+
* Clears the operation context and any sensitive data.
168+
*
169+
* @param[in,out] operation Pointer to the AEAD operation structure.
170+
*
171+
* @retval PSA_SUCCESS Operation aborted successfully.
172+
* @retval PSA_ERROR_NOT_SUPPORTED Unsupported algorithm.
173+
*/
174+
psa_status_t cracen_aead_abort(cracen_aead_operation_t *operation);
175+
176+
/**
177+
* @brief Perform a single software AEAD encryption.
178+
*
179+
* @param[in] attributes Key attributes.
180+
* @param[in] key_buffer Key material.
181+
* @param[in] key_buffer_size Size of key material.
182+
* @param[in] alg AEAD algorithm.
183+
* @param[in] nonce Nonce/IV.
184+
* @param[in] nonce_length Length of nonce.
185+
* @param[in] additional_data Additional data.
186+
* @param[in] additional_data_length Length of additional data.
187+
* @param[in] plaintext Plaintext to encrypt.
188+
* @param[in] plaintext_length Length of plaintext.
189+
* @param[out] ciphertext Output buffer for ciphertext and tag.
190+
* @param[in] ciphertext_size Size of ciphertext buffer.
191+
* @param[out] ciphertext_length Pointer to store actual output length.
192+
*
193+
* @retval PSA_SUCCESS Encryption completed successfully.
194+
* @retval PSA_ERROR_NOT_SUPPORTED Unsupported algorithm.
195+
* @retval PSA_ERROR_BUFFER_TOO_SMALL Output buffer too small.
196+
* @retval PSA_ERROR_INVALID_ARGUMENT Invalid parameters.
197+
*/
198+
psa_status_t cracen_aead_encrypt(const psa_key_attributes_t *attributes, const uint8_t *key_buffer,
199+
size_t key_buffer_size, psa_algorithm_t alg, const uint8_t *nonce,
200+
size_t nonce_length, const uint8_t *additional_data,
201+
size_t additional_data_length, const uint8_t *plaintext,
202+
size_t plaintext_length, uint8_t *ciphertext,
203+
size_t ciphertext_size, size_t *ciphertext_length);
204+
205+
/**
206+
* @brief Perform a single software AEAD decryption.
207+
*
208+
* @param[in] attributes Key attributes.
209+
* @param[in] key_buffer Key material.
210+
* @param[in] key_buffer_size Size of key material.
211+
* @param[in] alg AEAD algorithm.
212+
* @param[in] nonce Nonce/IV.
213+
* @param[in] nonce_length Length of nonce.
214+
* @param[in] additional_data Additional data.
215+
* @param[in] additional_data_length Length of additional data.
216+
* @param[in] ciphertext Ciphertext and tag to decrypt.
217+
* @param[in] ciphertext_length Length of ciphertext (including tag).
218+
* @param[out] plaintext Output buffer for plaintext.
219+
* @param[in] plaintext_size Size of plaintext buffer.
220+
* @param[out] plaintext_length Pointer to store actual plaintext length.
221+
*
222+
* @retval PSA_SUCCESS Decryption and verification completed successfully.
223+
* @retval PSA_ERROR_NOT_SUPPORTED Unsupported algorithm.
224+
* @retval PSA_ERROR_INVALID_SIGNATURE Tag verification failed.
225+
* @retval PSA_ERROR_BUFFER_TOO_SMALL Output buffer too small.
226+
* @retval PSA_ERROR_INVALID_ARGUMENT Invalid parameters.
227+
*/
228+
psa_status_t cracen_aead_decrypt(const psa_key_attributes_t *attributes, const uint8_t *key_buffer,
229+
size_t key_buffer_size, psa_algorithm_t alg, const uint8_t *nonce,
230+
size_t nonce_length, const uint8_t *additional_data,
231+
size_t additional_data_length, const uint8_t *ciphertext,
232+
size_t ciphertext_length, uint8_t *plaintext,
233+
size_t plaintext_size, size_t *plaintext_length);
234+
235+
/**
236+
* @}
237+
*/
238+
239+
#endif /* CRACEN_SW_AEAD_H */

0 commit comments

Comments
 (0)