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_STATUS | (status SRAM register) +----+--------------------+ |0x83| AES_CTRL | (configuration SRAM register) +----+--------------------+ |0x84| | | | AES_STATE_KEY | (128 bit data SRAM block) |0x93| | +----+--------------------+ |0x94| AES_CTRL_MIRROR | (configuration mirror SRAM 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 | The parameter configures the AES operation direction {AES_DIR_ENCRYPT, AES_DIR_DECRYPT}. | |
| aeskey | a data block of size TRX_AES_BLOCK_SIZE, storing the 128 bit AES key. | |
| idata | an input data block of size TRX_AES_BLOCK_SIZE, which can be either plain text or cypher text. | |
| idata1 | 1st input data block. | |
| idata2 | 2nd input data block. ... | |
| idataN | Nth input data block. |
| aesdone | value that indicates the current status of the AES module. {0}: operation is not finished, {1}: operation is finished. | |
| aeserror | value that indicates the error status of the AES module. {0}: no error has occured, {1}: an error has occured. | |
| odata | an output data block of size TRX_AES_BLOCK_SIZE, which can be either plain text or cypher text. | |
| odata1 | 1st output data block. | |
| odata2 | 2nd output data block. ... | |
| odataN | Nth output data block. |
/* AT86RF212::[ACTIVE] */ trx_sram_read(AES_STATUS, 1, stat); aesdone=stat & 1; aeserror=(stat>>7) & 1;
This steps can be combined using a single SRAM access, implemented with the function trx_aes_write() (for details refer to section AES Block Access and Fast SRAM Access).
/* AT86RF212::[ACTIVE] */ trx_aes_write(AES_MODE_KEY, 0, aeskey);
/* AT86RF212::[ACTIVE] */ trx_aes_read(AES_MODE_KEY, aeskey);
/* AT86RF212::[ACTIVE] */ aesctl = AES_MODE_ECB | aesdir; trx_aes_write(aesctl, 1, idata); delay(t12); trx_aes_read(aesctl, odata);
/* AT86RF212::[ACTIVE] */ aesctl = AES_MODE_ECB | aesdir; trx_aes_write(aesctl, 1, idata1); delay(t12); trx_aes_wrrd(aesctl, 1, idata2, odata1); delay(t12); trx_aes_wrrd(aesctl, 1, idata3, odata2); proc_other_blocks(); delay(t12); trx_aes_read(aesctl, odataN);
/* AT86RF212::[ACTIVE] */ aesctl = AES_MODE_ECB | aesdir; trx_aes_write(aesctl, 1, idata1); aesctl = AES_MODE_CBC | aesdir; trx_aes_wrrd(aesctl, 1, idata2, odata1); delay(t12); trx_aes_wrrd(aesctl, 1, idata3, odata2); proc_other_blocks(); delay(t12); trx_aes_read(aesctl, odataN);
1.5.6