Skip to content

Commit 4a9cce2

Browse files
Vge0rgecarlescufi
authored andcommitted
nrf_security: Fix for PSA MAC context in Cracen
There is an input_buffer in the Cracen MAC driver which is used to store intermediate data when needed. The size of this buffer was chosen based on the maximum hash block size. Since there was some hash optimizations merged earlier the maximum hash block size can now be 1 and this is problematic for cases where only CMAC is being used. This fixes this by setting the buffer accortingly when only CMAC is enabled. Signed-off-by: Georgios Vasilakis <[email protected]> (cherry picked from commit 99b35cb)
1 parent 1751b20 commit 4a9cce2

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

subsys/nrf_security/src/drivers/cracen/cracenpsa/include/cracen_psa_primitives.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ struct cracen_mac_operation_s {
190190
size_t bytes_left_for_next_block;
191191

192192
/* Buffer for input data to fill up the next block */
193-
uint8_t input_buffer[SX_HASH_MAX_ENABLED_BLOCK_SIZE];
193+
uint8_t input_buffer[SX_MAX(SX_HASH_MAX_ENABLED_BLOCK_SIZE, SX_BLKCIPHER_PRIV_SZ)];
194194

195195
union {
196196
struct {
@@ -214,7 +214,7 @@ struct cracen_key_derivation_operation {
214214
psa_algorithm_t alg;
215215
enum cracen_kd_state state;
216216
uint64_t capacity;
217-
uint8_t output_block[SX_HASH_MAX_ENABLED_BLOCK_SIZE];
217+
uint8_t output_block[SX_MAX(SX_HASH_MAX_ENABLED_BLOCK_SIZE, SX_BLKCIPHER_PRIV_SZ)];
218218
uint8_t output_block_available_bytes;
219219
union{
220220
cracen_mac_operation_t mac_op;

subsys/nrf_security/src/drivers/cracen/sxsymcrypt/include/sxsymcrypt/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ extern "C" {
2121
#define SX_BLKCIPHER_PRIV_SZ (16)
2222
#define SX_AEAD_PRIV_SZ (70)
2323

24+
#define SX_MAX(p, q) ((p >= q) ? p : q)
25+
2426
/** Mode Register value for context loading */
2527
#define BA417_MODEID_CTX_LOAD (1u << 5)
2628
/** Mode Register value for context saving */

0 commit comments

Comments
 (0)