The Multiple key(Key Rolling) or Single key encrypted images will have the same format. The images include:
- Secure header - This includes the dummy AES key of 32byte + Block 0 IV of 12byte + DLC for Block 0 of 4byte + GCM tag of 16byte(Un-Enc).
- Block N - This includes the boot image data for the block N of n size + Block N+1 AES key of 32byte + Block N+1 IV of 12byte + GCM tag for Block N of 16byte(Un-Enc).
The Secure header and Block 0 will be decrypted using the device key or user provided key. If more than one block is found then the key and the IV obtained from previous block will be used for decryption.
Following are the instructions to decrypt an image:
- Read the first 64 bytes and decrypt 48 bytes using the selected Device key.
- Decrypt Block 0 using the IV + Size and the selected Device key.
- After decryption, you will get the decrypted data+KEY+IV+Block Size. Store the KEY/IV into KUP/IV registers.
- Using Block size, IV and the next Block key information, start decrypting the next block.
- If the current image size is greater than the total image length, perform the next step. Else, go back to the previous step.
- If there are failures, an error code is returned. Else, the decryption is successful.