Assuming initialization from reset
state and that CHA has written new plaintext to BUF before reading ciphertext,
denoting plaintext as an array, m[1:x]:
Initialization:
- Write KEY0-KEY3
- Set AUTOCFG:
- AESSRC = BUF
- TRGAES = RDTXT3 |
WRBUF3S
Cipher mode with µDMA:
- µDMA channel A moves m[1:x] into
BUF when AES operation starts
- ADRCHA = BUF0
- TRGCHA = AESSTART
- DONEACT =
GATE_TRGAES_ON_CHA_DEL (to avoid spurious last AES operation). In case
of single block encryption, configure DONEACT = GATE_TRGAES_ON_CHA.
- µDMA channel B moves
ciphertext[1:x] to memory when AES completes.
- ADRCHB = TXT0
- TRGCHB = AESDONE
- START: CPU writes 0x1 to
TRG.DMACHA
- END : CPU waits for µDMA 'done'
Cipher mode with CPU:
- Writes m[1] to BUF (triggers AES
operation)
- for i = 1; i<x, increment i:
- Prepares m[i+1]
- Wait until STA.STATE =
BUSY || use interrupt (This can be skipped since AES is immediately
triggered)
- Writes m[i+1] to BUF
- Waits for STA.STATE =
IDLE || use interrupt
- Reads ciphertext[i] from
TXT
- Last m(x):
- Set AUTOCFG.TRGAES =
DISABLE
- 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
operation is triggered on the last read of TXT3. This can be aborted immediately
after completing the x-th iteration of the for-loop.