Skip to content

Commit 7102299

Browse files
degjorvanordicjm
authored andcommitted
nrf_security: cracen_sw: Update counter size in counter mode
Use the fully 16-byte block as the counter to align with CRACEN implementation. Signed-off-by: Dag Erik Gjørvad <[email protected]>
1 parent 86d098b commit 7102299

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

subsys/nrf_security/src/drivers/cracen/cracen_sw/src/cracen_sw_aes_ctr.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@
2121
#include <cracen_sw_common.h>
2222
#include "cracen_sw_aes_ctr.h"
2323

24-
/* AES CTR mode counter field is the rightmost 32 bits (4 bytes) of the 16-byte block */
24+
/* AES CTR mode counter field is the entire 16-byte block */
2525
#define AES_BLOCK_LAST_BYTE_INDEX (SX_BLKCIPHER_AES_BLK_SZ - 1)
26-
#define AES_CTR_COUNTER_START_BYTE (SX_BLKCIPHER_AES_BLK_SZ - 4)
26+
#define AES_CTR_COUNTER_START_BYTE 0
2727

28-
/* Increments the counter by one block */
2928
static void increment_counter(uint8_t *ctr)
3029
{
31-
/* CTR mode increments the rightmost 32 bits in big-endian */
3230
for (int i = AES_BLOCK_LAST_BYTE_INDEX; i >= AES_CTR_COUNTER_START_BYTE; i--) {
3331
if (++ctr[i] != 0) {
3432
break;

0 commit comments

Comments
 (0)