Changes

Jump to navigation Jump to search
543 bytes added ,  20:28, 30 January 2016
no edit summary
Line 17: Line 17:  
| 0x10009004
 
| 0x10009004
 
| 4
 
| 4
| W?
+
| W
 
|-
 
|-
 
| style="background: green" | Yes
 
| style="background: green" | Yes
Line 138: Line 138:  
| 25
 
| 25
 
| Input word order (1=Normal order, 0=Reversed order)
 
| Input word order (1=Normal order, 0=Reversed order)
|-
   
|-
 
|-
 
| 26
 
| 26
| Update keyslot (selects the keyslot specified by REG_AESKEYSEL when this bit is set)
+
| Update keyslot (selects the keyslot specified by AES_KEYSEL when this bit is set)
 
|-
 
|-
 
| 29-27
 
| 29-27
Line 153: Line 152:  
|}
 
|}
   −
When bit31 is clear, the AES engine will handle keyslot-selection when bit26 is set immediately. When bit31 is set, the AES engine won't handle bit26 immediately, instead the AES engine will automatically handle the already-set bit26 once bit31 clears(current AES operation finishes).
+
When bit31 is set, this register essentially becomes locked and doesn't change when written to. However if bit26 is "set", keyslot-selection is cued to be handled when bit31 is cleared.
    
Clearing bit31 while the AES engine is doing crypto will result in the AES engine stopping crypto, once it finishes processing the current block.
 
Clearing bit31 while the AES engine is doing crypto will result in the AES engine stopping crypto, once it finishes processing the current block.
 +
 +
Read/Write FIFO counts and the MAC status can never be set by writing to AES_CNT, they are read-only.
 +
 +
Changing the input word order triggers the key/keyX/keyY FIFOs to be flushed.
    
== AES_BLKCNT ==
 
== AES_BLKCNT ==
Line 164: Line 167:  
|-
 
|-
 
| 16-31
 
| 16-31
| (Data length)>>4
+
| (Data length)>>4 (i.e. the number of blocks to process)
 
|}
 
|}
   Line 170: Line 173:  
Up to 128 bytes of input data can be buffered.
 
Up to 128 bytes of input data can be buffered.
   −
The input data for the AES crypto operation is written to REG_AESWRFIFO, the output data is read from REG_AESRDFIFO.
+
The input data for the AES crypto operation is written to AES_WRFIFO, the output data is read from AES_RDFIFO.
 +
 
 +
Reading from AES_RDFIFO when there's no data available in the RDFIFO will result in reading the last word that was in the RDFIFO.
 +
 
 +
When triggering either RDFIFO or WRFIFO to be flushed, the AES Engine does not clear either buffer.
   −
Reading from REG_AESRDFIFO when there's no data available in the RDFIFO will result in reading the last word that was in the RDFIFO.
+
Word order and endianness can be changed between each read/write to these FIFOs. However changing the word order when writing to WRFIFO can cause the word to be written outside the current block, leaving uninitialized data in its place. Attempts to change endianness or word order are not honored when reading from RDFIFO when no more data is available.
    
== AES_KEYCNT ==
 
== AES_KEYCNT ==
Line 217: Line 224:     
== Endianness and word order ==
 
== Endianness and word order ==
When writing to the AES_CTR or AES_MAC register, the hardware will process the written data according to the current input endianness specified in AES_CNT. However, the current specified input word order will not be honored for this register, and always defaults to reversed word order. Therefore, for normal word order, the reversal must be carried out manually if required.
+
When writing to the AES_CTR, AES_MAC or AES_KEY0/1/2/3 register, the hardware will process the written data according to the current input endianness specified in AES_CNT. However, the current specified input word order will not be honored for this register, and always defaults to reversed word order. Therefore, for normal word order, the reversal must be carried out manually if required.
    
== Keyslot ranges ==
 
== Keyslot ranges ==
Line 611: Line 618:     
=== Updating keydata ===
 
=== Updating keydata ===
The contents of the keyslot specified in REG_AESKEYCNT can be updated by consecutively writing four words to REG_AESKEYXFIFO (keyX), REG_AESKEYYFIFO(keyY), or REG_AESKEYFIFO (normalkey).
+
The contents of the keyslot specified in AES_KEYCNT can be updated by consecutively writing four words to AES_KEYXFIFO (keyX), AES_KEYYFIFO(keyY), or AES_KEYFIFO (normalkey).
   −
After writing to a keyslot, the keyslot must be selected again(write REG_AESKEYSEL + set REG_AESCNT bit26), even when writing to the same keyslot. Writing the last word to a key FIFO immediately after selecting a keyslot will not affect the keyslot keydata that gets used at that time, the new keydata will not get used until the keyslot gets selected again.
+
After writing to a keyslot, the keyslot must be selected again(write AES_KEYSEL + set AES_CNT bit26), even when writing to the same keyslot. Writing the last word to a key FIFO immediately after selecting a keyslot will not affect the keyslot keydata that gets used at that time, the new keydata will not get used until the keyslot gets selected again.
    
Writing to the key FIFOs with byte writes results in the AES engine converting the byte to a word for setting the key word, with this: word = (byteval) | (byteval<<8) | (byteval<<16) | (byteval<<24). The result is the same regardless of which FIFO register byte was written to.
 
Writing to the key FIFOs with byte writes results in the AES engine converting the byte to a word for setting the key word, with this: word = (byteval) | (byteval<<8) | (byteval<<16) | (byteval<<24). The result is the same regardless of which FIFO register byte was written to.
   −
The TWL keyslots 0x00-0x03 can be set directly by writing to the REG_AESKEY0-REG_AESKEY3 registers.
+
The TWL keyslots 0x00-0x03 can be set directly by writing to the AES_KEY0-AES_KEY3 registers.
   −
The key FIFOs can be written simultaneously. For example, executing the following 4 times will result in the keyX and keyY being set to all-zero(unknown for normalkey): memset(0x10009100, 0, 0x100);
+
The key FIFOs can be written simultaneously. For example, executing the following will result in the keyX and keyY being set to all-zero(unknown for normalkey): memset(0x10009100, 0, 0x100);
   −
Each key FIFO has a 0x10-byte tmp-buffer for storing the words written to that FIFO. Once the last word is written to a key FIFO, the filled tmp-buffer is then written to the key-data for the keyslot selected by REG_AESKEYCNT at the time the last word was written.
+
Each key FIFO has a 0x10-byte tmp-buffer for storing the words written to that FIFO. Once the last word is written to a key FIFO, the filled tmp-buffer is then written to the key-data for the keyslot selected by AES_KEYCNT at the time the last word was written.
    
=== Hardware key generator ===
 
=== Hardware key generator ===
11

edits

Navigation menu