ECB — AES electronic codebook mode encryption

nRF54L15 | nRF54L10 | nRF54L05 Datasheet

The AES electronic codebook mode encryption (ECB) can be used for a range of cryptographic functions like hash generation, digital signatures, and keystream generation for data encryption/decryption. The ECB encryption block supports 128 bit AES encryption (encryption only, not decryption).

The main features of ECB are:

  • 128-bit AES encryption
  • Supports standard AES ECB block encryption
  • Memory-to-memory operations using Scatter/Gather DMA

The inputs and outputs of the ECB are illustrated below.

Figure 1. ECB block diagram

Page-1 Class.457 Sheet.7 Sheet.8 Sheet.9 Sheet.10 Sheet.11 ECB ECB Sheet.12 Sheet.13 START START Sheet.14 Sheet.15 INPTR INPTR Sheet.16 Sheet.17 Sheet.18 END END Sheet.19 OUTPTR OUTPTR Sheet.20 Sheet.21 ERROR ERROR Sheet.22 Sheet.23 STOP STOP

AES ECB uses EasyDMA with scatter-gather to access to memory for in-place operations on cleartext and ciphertext during encryption. ECB uses the same AES core as the CCM and AAR blocks and is an asynchronous operation which may not complete if the AES core is busy.

AES ECB performs a 128 bit AES block encrypt. At the START task, cleartext is loaded into the ECB from memory described by the scatter/gather job list pointed to by INPTR and the ciphertext is written into memory described by the job list pointed to by OUTPTR. When the last cleartext byte has been encrypted and written to OUTPTR, the END event is triggered.

The following figure illustrates how the input and output job lists can be configured. For more details of the joblists, see EasyDMA.

Figure 2. Example job lists for ECB operation

Example job lists for ECB operation

The AES key is set by writing the KEY.VALUE key registers. The same key can be used to encrypt multiple blocks by triggering the START task multiple times.

AES ECB can be stopped by triggering the STOP task.

ECB only supports a single 16-byte block. For different job list sizes the following rules apply:
  • If less than 16 bytes is supplied as input, then a PrematureInptrEnd error is triggered. The EVENTS_ERROR will also be set.
  • If more than 16 bytes is supplied as input, then only the first 16 bytes are used.
  • For an output job, only the number of bytes specified in the job list are copied to memory.
The 128-bit key in the KEY.VALUE registers is stored in reverse byte order relative to the payload. For example, using the sample calculation from the Bluetooth Core Specification v5.4, Volume 6, Part C, chapter 1.1, with the following data:
  • Key: 4C68384139F574D836BCF34E9DFB01BF
  • Plaintext: 0213243546576879acbdcedfe0f10213
  • Expected Encrypted Output: 99ad1b5226a37e3e058e3b8e27c2c666
The KEY.VALUE registers are populated as follows: The IN.PTR points to a job that contains the following 16-byte input data array:

          {0x02, 0x13, 0x24, 0x35, 0x46, 0x57, 0x68, 0x79, 0xAC, 0xBD, 0xCE, 0xDF, 0xE0, 0xF1, 0x02, 0x13}
      
Once the encryption is complete, the output buffer referenced by the output job will be filled with the following 16-byte array:

          {0x99, 0xAD, 0x1B, 0x52, 0x26, 0xA3, 0x7E, 0x3E, 0x05, 0x8E, 0x3B, 0x8E, 0x27, 0xC2, 0xC6, 0x66}
      
Note: The KEY byte order is reversed compared to the NRF52 and NRF53 series devices.