Assuming initialization from reset state and
denoting plaintext as an array, m[1:x]:
Initialization:
- Write KEY0-KEY3
- AUTOCFG
- AESSRC = TXTXBUF
- TRGAES = WRBUF3
- TRGTXT = RDTXT3
- Write IV to TXT
Cipher mode with
µDMA:
- µDMA channel A moves m[1:x] into
BUF on TXT3 read.
- ADRCHA = BUF0
- TRGCHA = RDTXT3
- DONEACT =
GATE_TRGAES_ON_CHA (to avoid spurious last AES using µDMA)
- µDMA channel B gets
ciphertext[1:x] by reading TXT when AES completes.
- ADRCHB = TXT0
- TRGCHB = AESDONE (
Completion of each burst updates TXT <= TXT XOR BUF, and triggers
channel A)
- START: SW starts the process by
writing 0x1 to TRG.DMACHA
- END: SW waits for µDMA to signal
'done'.
Cipher mode with
CPU:
- for i = 1; i<x, increment i:
- Write m[i] to BUF
- Waits for STA.STATE =
IDLE || use interrupt
- Reads ciphertext[i] from
TXT
- Last m(x):
- Set AUTOCFG.TRGAES =
DISABLE
- Writes m[x] to BUF
- Waits for STA.STATE =
IDLE || use interrupt
- Reads ciphertext[x] from
TXT
Note: The loop can run over i=1:x, but then an additional AES
encryption is triggered on the last read of TXT3. This can be aborted immediately
after completing the x-th iteration of the for-loop.