Below are the steps for CFB
encryption with 16-byte block size.
Assuming initialization from reset state and
denoting plaintext as an array, m[1:x]:
Initialization:
- Write KEY0-KEY3
- SW initializes TXT with
(Initialization Vector) IV
- AUTOCFG
- AESSRC = TXT
- TRGAES = RDTXT3 (reading
TXTXBUF3 also causes trigger, see register information)
- TRGTXT = RDTXTXBUF3
Cipher mode with
µDMA:
Assumes CHA has
written new plaintext to BUF before reading ciphertext:
- µDMA channel A moves m[1:x] into
BUF when AES starts
- ADRCHA = BUF0
- TRGCHA = AESSTART
- DONEACT =
GATE_TRGAES_ON_CHA(to avoid spurious last AES using µDMA)
- µDMA channel B gets
ciphertext[1:x] by reading TXTXBUF when AES completes.
- ADRCHB = TXTXBUF0
- TRGCHB = AESDONE
- START: CPU writes 'TXT' to
TRG.OP to start first AES.
- END: CPU waits for µDMA to
signal 'done'.
Cipher mode with
CPU:
- Writes 'TXT' to TRG.OP to start
first AES.
- for i = 1; i<x, increment i:
- Waits until STA.STATE =
BUSY || use interrupt (This can be skipped since AES is immediately
triggered)
- Writes m[i] to BUF
- Waits for STA.STATE =
IDLE || use interrupt
- Reads ciphertext[i] from
TXTXBUF (TXT <= TXT XOR BUF (what was just read), triggers new
encryption)
- Last m(x):
- Set AUTOCFG.TRGAES =
DISABLE
- Waits until STA.STATE =
BUSY || use interrupt (This can be skipped since AES is immediately
triggered)
- Writes m[i] to BUF
- Waits for STA.STATE =
IDLE || use interrupt
- Reads ciphertext[x] from
TXTXBUF
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.