The security module can be accessed with SRAM read/write commands (see section SRAM Access Mode) in any of the [ACTIVE] states. The functions trx_aes_read(), trx_aes_wrrd(), trx_aes_write() are adapted SRAM read/write functions, which take the memory organization of the security module into consideration. The fast SRAM access method is described in detail in section AES Block Access and Fast SRAM Access. The following picture shows the memory map of the security module.
+----+--------------------+ |0x82| AES_STATE | (status register) +----+--------------------+ |0x83| AES_CTRL | (configuration register) +----+--------------------+ |0x84| | | | AES_STATE_KEY | (128 bit data block) |0x93| | +----+--------------------+ |0x94| AES_CTRL (MIRROR) | (configuration mirror register) +----+--------------------+
Performing an AES operation requires the following steps:
| aesmode | This parameter configures the AES operational mode, which can be {AES_MODE_KEY, AES_MODE_ECB, AES_MODE_CBC}. All other values are reserved. | |
| aesdir | This parameter configures the AES operation direction {AES_DIR_ENCRYPT, AES_DIR_DECRYPT}. | |
| aeskey | This data block of size TRX_AES_BLOCK_SIZE stores the 128 bit AES key. | |
| idata | This input data block of size TRX_AES_BLOCK_SIZE can contain either plain text or cypher text. | |
| {idata1} | 1st input data block. | |
| {idata2} | 2nd input data block. ... | |
| {idataN} | Nth input data block. | |
| [out] | aesstatus | This value indicates the current status of the AES module. {0}: operation is not finished, {1}: operation is finished. |
| [out] | {odata} | This output data block of size TRX_AES_BLOCK_SIZE, contains either plain text or cypher text. |
| [out] | {odata1} | 1st output data block. |
| [out] | {odata2} | 2nd output data block. ... |
| [out] | {odataN} | Nth output data block. |
/* AT86RF231::[ACTIVE] */ trx_sram_read(AES_STATE, 1, aesstatus); aesstatus=aesstatus&1;
/* AT86RF231::[ACTIVE] */ trx_sram_read(AES_CTRL, 1, aesctrl); aesmode=(aesctrl>>4)&7; aesdir=(aesctrl>>3)&1;
/* AT86RF231::[ACTIVE] */ trx_aes_write(AES_MODE_KEY, 0, aeskey);
/* AT86RF231::[ACTIVE] */ trx_aes_read(AES_MODE_KEY, aeskey);
/* AT86RF231::[ACTIVE] */ aesctrl = AES_MODE_ECB | aesdir; trx_aes_write(aesctrl, 1, idata); delay(t12); trx_aes_read(aesctrl, odata);
/* AT86RF231::[ACTIVE] */ aesctrl = AES_MODE_ECB | aesdir; trx_aes_write(aesctrl, 1, idata1); delay(t12); trx_aes_wrrd(aesctrl, 1, idata2, odata1); delay(t12); trx_aes_wrrd(aesctrl, 1, idata3, odata2); proc_other_blocks(); delay(t12); trx_aes_read(aesctrl, odataN);
/* AT86RF231::[ACTIVE] */ aesctrl = AES_MODE_ECB | aesdir; trx_aes_write(aesctrl, 1, idata1); aesctrl = AES_MODE_CBC | aesdir; trx_aes_wrrd(aesctrl, 1, idata2, odata1); delay(t12); trx_aes_wrrd(aesctrl, 1, idata3, odata2); proc_other_blocks(); delay(t12); trx_aes_read(aesctrl, odataN);
1.5.2