|
C8051F960-B-GM Datasheet, PDF (180/492 Pages) Silicon Laboratories – Ultra Low Power 128K, LCD MCU Family | |||
|
◁ |
C8051F96x
14.2.1. Key Inversion using DMA
Normally, the AES block is used with the DMA. This provides the best performance and lowest power con-
sumption. Code examples are provided in 8051 compiler independent C code using the DMA. It is highly
recommended to use the code examples. The steps are listed here for completeness.
Steps to generate the Decryption Key from Encryption Key
ï® Prepare encryption key and dummy data in xram.
ï® Reset AES module by clearing bit 3 of AES0BCFG.
ï® Disable the first three DMA channels by clearing bits 0 to 2 in the DMA0EN sfr.
ï® Configure the first DMA channel for the AES0KIN sfr.
ï¬ï Select the first DMA channel by writing 0x00 to the DMA0SEL sfr.
ï¬ï Configure the first DMA channel to move xram to AES0KIN sfr by writing 0x05 to the DMA0NCF sfr.
ï¬ï Clear DMA0NMD to disable wrapping.
ï¬ï Write the xram address of the encryption key to the DMA0NBAH and DMA0NBAL sfrs.
ï¬ï Write the key length in bytes to DMA0NSZL sfr.
ï¬ï Clear DMA0NSZH
ï¬ï Clear DMA0NAOH and DMA0NAOL.
ï® Configure the second DMA channel for the AES0BIN sfr.
ï¬ï Select the second DMA channel by writing 0x01 to the DMA0SEL sfr.
ï¬ï Configure the second DMA channel to move xram to AES0BIN sfr by writing 0x06 to the DMA0NCF sfr.
ï¬ï Clear DMA0NMD to disable wrapping.
ï¬ï Write the xram address of dummy data to the DMA0NBAH and DMA0NBAL sfrs.
ï¬ï Write 0x10 (16) to the DMA0NSZL sfr.
ï¬ï Clear DMA0NSZH
ï¬ï Clear DMA0NAOH and DMA0NAOL
ï® Configure the third DMA channel for the AES0YOUT sfr.
ï¬ï Select the third DMA channel by writing 0x02 to the DMA0SEL sfr.
ï¬ï Configure the third DMA channel to move the contents of the AES0YOUT sfr to xram by writing 0x08 to the
DMA0NCF sfr.
ï¬ï Enable transfer complete interrupt by setting bit 7 of DMA0NCF sfr.
ï¬ï Clear DMA0NMD to disable wrapping.
ï¬ï Write the xram address for the decryption key to the DMA0NBAH and DMA0NBAL sfrs.
ï¬ï Write the key length in bytes to DMA0NSZL sfr.
ï¬ï Clear DMA0NSZH.
ï¬ï Clear DMA0NAOH and DMA0NAOL.
ï® Clear first three DMA interrupts by clearing bits 0 to 2 in the DMA0INT sfr.
ï® Enable first three DMA channels setting bits 0 to 2 in the DMA0EN sfr
ï® Configure the AES Module data flow for inverse key generation by writing 0x04 to the AES0DCFG sfr.
ï® Write key size to bits 1 and 0 of the AES0BCFG.
ï® Configure the AES core for encryption by setting the bit 2 of AES0BCFG.
ï® Initiate the encryption operation by setting bit 3 of AES0BCFG.
ï® Wait on the DMA interrupt from DMA channel 2.
ï® Disable the AES Module by clearing bit 2 of AES0BCFG.
ï® Disable the DMA by writing 0x00 to DMA0EN.
180
Rev. 1.0
|
▷ |