AES-GCM - 2020.2 English

OS and Libraries Document Collection (UG643)

Document ID
UG643
Release Date
2020-11-24
Version
2020.2 English

This software uses AES-GCM hardened cryptographic accelerator to encrypt or decrypt the provided data and requires a key of size 256 bits and initialization vector(IV) of size 96 bits.

XilSecure library supports the following features:

  • Encryption of data with provided key and IV
  • Decryption of data with provided key and IV
  • Authentication using a GCM tag.
  • Key loading based on key selection, the key can be either the user provided key loaded into the KUP key or the device key used during boot.

For either encryption or decryption the AES-GCM engine should be initialized first using the XSecure_AesInitialize function.

When all the data to be encrypted is available, the XSecure_AesEncryptData() can be used. When all the data is not available, use the following functions in the suggested order:

  1. XSecure_AesEncryptInit()
  2. XSecure_AesEncryptUpdate() - This function can be called multiple times till input data is completed.

When all the data to be decrypted is available, the XSecure_AesDecryptData() can be used. When all the data is not available, use the following functions in the suggested order:

  1. XSecure_AesDecryptInit()
  2. XSecure_AesDecryptUpdate() - This function can be called multiple times till input data is completed.

During decryption, the provided GCM tag is compared to the GCM tag calculated by the engine. The two tags are then compared in the software and returned to the user as to whether or not the tags matched.

CAUTION:
when using the KUP key for encryption/decryption of the data, where the key is stored should be carefully considered. Key should be placed in an internal memory region that has access controls. Not doing so may result in security vulnerability.
Table 1. Quick Function Reference
Type Name Arguments
s32 XSecure_AesInitialize
  • XSecure_Aes * InstancePtr
  • XCsuDma * CsuDmaPtr
  • u32 KeySel
  • u32 * IvPtr
  • u32 * KeyPtr
u32 XSecure_AesDecryptInit
  • XSecure_Aes * InstancePtr
  • u8 * DecData
  • u32 Size
  • u8 * GcmTagAddr
s32 XSecure_AesDecryptUpdate
  • XSecure_Aes * InstancePtr
  • u8 * EncData
  • u32 Size
s32 XSecure_AesDecryptData
  • XSecure_Aes * InstancePtr
  • u8 * DecData
  • u8 * EncData
  • u32 Size
  • u8 * GcmTagAddr
s32 XSecure_AesDecrypt
  • XSecure_Aes * InstancePtr
  • const u8 * Src
  • u8 * Dst
  • u32 Length
u32 XSecure_AesEncryptInit
  • XSecure_Aes * InstancePtr
  • u8 * EncData
  • u32 Size
u32 XSecure_AesEncryptUpdate
  • XSecure_Aes * InstancePtr
  • const u8 * Data
  • u32 Size
u32 XSecure_AesEncryptData
  • XSecure_Aes * InstancePtr
  • u8 * Dst
  • const u8 * Src
  • u32 Len
void XSecure_AesReset
  • XSecure_Aes * InstancePtr