Assuming initialization from reset state and denoting plaintext as an array,
m[1:x]:
Initialization:
- Write KEY0-KEY3
- AUTOCFG
- AESSRC = BUF
- TRGAES = RDTXT3 |
WRBUF3S (the first encryption starts by writing BUF3, the successive
ones by reading TXT3)
- CTRSIZE =
CTR8/CTR16/CTR32/CTR64/CTR128
Cipher mode with µDMA:
- µDMA channel A moves m[1:x] into
TXTX when AES completes
- ADRCHA = TXTX0
- TRGCHA = AESDONE
- DONEACT =
GATE_TRGAES_ON_CHA (to avoid spurious last AES using µDMA)
- µDMA channel B moves
ciphertext[1:x] to memory after channel A has written TXTX3
- ADRCHB = TXT0
- TRGCHB = WRTXT3
- START: SW initializes BUF with
data corresponding to nonce, flags, and counter. This triggers first AES
operation
- END : CPU waits for µDMA to
signal 'done'
Cipher mode with CPU:
- Initializes BUF with data
corresponding to nonce, flags, and counter. This triggers first AES
operation
- for i=1; i<x; increment i:
- Waits for STA.STATE =
IDLE || use interrupt
- Writes plaintext[i] to
TXTX0-TXTX3
- Reads ciphertext[i]
- Set AUTOCFG.TRGAES =DISABLE
- Waits for STA.STATE = IDLE ||
use interrupt
- Writes plaintext[i] to
TXTX0-TXTX3
- Reads ciphertext[i]
Note: The loop can run over i=1:x, but then an additional AES
operation is triggered on the last read of TXT3. This can be aborted immediately
after completing the x-th iteration of the for-loop.