TrustCore SDK Crypto Interface API reference  version 2.0
crypto_interface_aes_gcm.h File Reference

Cryptographic Interface header file for declaring AES-GCM functions. More...

Go to the source code of this file.

Functions

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_AES_GCM_decrypt (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pNonce, ubyte4 nonceLen, ubyte *pAad, ubyte4 aadLen, ubyte *pData, ubyte4 dataLen, ubyte4 tagLen)
 Decrypt and verify a buffer of data via the AES-GCM algorithm. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_AES_GCM_deleteCtx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *ppCtx)
 Deletes and frees memory associated with an AES-GCM context of type AES_GCM_CTX. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_AES_GCM_encrypt (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pNonce, ubyte4 *pNonceLen, intBoolean *pWasNonceUsed, ubyte *pAad, ubyte4 aadLen, ubyte *pData, ubyte4 dataLen, ubyte4 tagLen)
 Encrypt and tags a buffer of data via the AES-GCM algorithm. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_AES_GCM_newCtx (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *ppNewCtx, ubyte4 tableSizeMode, ubyte *pKeyMaterial, sbyte4 keyMaterialLen, sbyte4 encrypt)
 Create a new AES-GCM context of type AES_GCM_CTX for Authenticated Encrypt Authenticated Decrypt (AEAD) operations. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_cipher_256b (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pNonce, ubyte4 nonceLen, ubyte *pAaData, ubyte4 aadLen, ubyte *pData, ubyte4 dataLen, ubyte4 tagLen, sbyte4 encrypt)
 Perform an AES-GCM cipher operation in one step. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_cipher_4k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pNonce, ubyte4 nonceLen, ubyte *pAaData, ubyte4 aadLen, ubyte *pData, ubyte4 dataLen, ubyte4 tagLen, sbyte4 encrypt)
 Perform an AES-GCM cipher operation in one step. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_cipher_64k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pNonce, ubyte4 nonceLen, ubyte *pAaData, ubyte4 aadLen, ubyte *pData, ubyte4 dataLen, ubyte4 tagLen, sbyte4 encrypt)
 Perform an AES-GCM cipher operation in one step. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_clone_256b (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, BulkCtx *ppNewCtx)
 Clone a AES-GCM context. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_clone_4k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, BulkCtx *ppNewCtx)
 Clone a AES-GCM context. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_clone_64k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, BulkCtx *ppNewCtx)
 Clone a AES-GCM context. More...
 
MOC_EXTERN BulkCtx CRYPTO_INTERFACE_GCM_createCtx_256b (MOC_SYM(hwAccelDescr hwAccelCtx) ubyte *pKeyData, sbyte4 keyLen, sbyte4 encrypt)
 Create a new AES-GCM context for Authenticated Encrypt Authenticated Decrypt (AEAD) operations. More...
 
MOC_EXTERN BulkCtx CRYPTO_INTERFACE_GCM_createCtx_4k (MOC_SYM(hwAccelDescr hwAccelCtx) ubyte *pKeyData, sbyte4 keyLen, sbyte4 encrypt)
 Create a new AES-GCM context for Authenticated Encrypt Authenticated Decrypt (AEAD) operations. More...
 
MOC_EXTERN BulkCtx CRYPTO_INTERFACE_GCM_createCtx_64k (MOC_SYM(hwAccelDescr hwAccelCtx) ubyte *pKeyData, sbyte4 keyLen, sbyte4 encrypt)
 Create a new AES-GCM context for Authenticated Encrypt Authenticated Decrypt (AEAD) operations. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_deleteCtx_256b (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *pCtx)
 Delete an AES-GCM context previously created with CRYPTO_INTERFACE_GCM_createCtx_256b. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_deleteCtx_4k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *pCtx)
 Delete an AES-GCM context previously created with CRYPTO_INTERFACE_GCM_createCtx_4k. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_deleteCtx_64k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *pCtx)
 Delete an AES-GCM context previously created with CRYPTO_INTERFACE_GCM_createCtx_64k. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_final_256b (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte pTag[])
 Finish an AES-GCM operation to recieve the computed tag. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_final_4k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte pTag[])
 Finish an AES-GCM operation to recieve the computed tag. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_final_64k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte pTag[])
 Finish an AES-GCM operation to recieve the computed tag. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_final_ex_256b (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pTag, ubyte4 tagLen)
 Finalizes an AES-GCM context and verifies or outputs the tag. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_final_ex_4k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pTag, ubyte4 tagLen)
 Finalizes an AES-GCM context and verifies or outputs the tag. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_final_ex_64k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pTag, ubyte4 tagLen)
 Finalizes an AES-GCM context and verifies or outputs the tag. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_init_256b (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pNonce, ubyte4 nonceLen, ubyte *pAaData, ubyte4 aadLen)
 Initialize an AES-GCM context for a cipher operation. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_init_4k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pNonce, ubyte4 nonceLen, ubyte *pAaData, ubyte4 aadLen)
 Initialize an AES-GCM context for a cipher operation. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_init_64k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pNonce, ubyte4 nonceLen, ubyte *pAaData, ubyte4 aadLen)
 Initialize an AES-GCM context for a cipher operation. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_aad_256b (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pAadData, ubyte4 aadDataLen)
 Updates an AES-GCM context with additional authenticated data. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_aad_4k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pAadData, ubyte4 aadDataLen)
 Updates an AES-GCM context with additional authenticated data. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_aad_64k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pAadData, ubyte4 aadDataLen)
 Updates an AES-GCM context with additional authenticated data. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_data_256b (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pData, ubyte4 dataLen)
 Updates an AES-GCM context with data to be encrypted or decrypted. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_data_4k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pData, ubyte4 dataLen)
 Updates an AES-GCM context with data to be encrypted or decrypted. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_data_64k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pData, ubyte4 dataLen)
 Updates an AES-GCM context with data to be encrypted or decrypted. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_decrypt_256b (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pCipherText, ubyte4 cipherTextLen)
 Update an encryption operation. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_decrypt_4k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pCipherText, ubyte4 cipherTextLen)
 Update an encryption operation. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_decrypt_64k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pCipherText, ubyte4 cipherTextLen)
 Update an encryption operation. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_encrypt_256b (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pData, ubyte4 dataLen)
 Update an encryption operation. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_encrypt_4k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pData, ubyte4 dataLen)
 Update an encryption operation. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_encrypt_64k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pData, ubyte4 dataLen)
 Update an encryption operation. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_nonce_256b (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pNonce, ubyte4 nonceLen)
 Sets the nonce in a previously created AES-GCM Context. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_nonce_4k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pNonce, ubyte4 nonceLen)
 Sets the nonce in a previously created AES-GCM Context. More...
 
MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_nonce_64k (MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx pCtx, ubyte *pNonce, ubyte4 nonceLen)
 Sets the nonce in a previously created AES-GCM Context. More...
 

Detailed Description

Function Documentation

◆ CRYPTO_INTERFACE_AES_GCM_decrypt()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_AES_GCM_decrypt ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pNonce,
ubyte4  nonceLen,
ubyte *  pAad,
ubyte4  aadLen,
ubyte *  pData,
ubyte4  dataLen,
ubyte4  tagLen 
)
Parameters
pCtxPointer to a context of type AES_GCM_CTX to use for this cipher operation.
pNonceBuffer to hold nonce input to the cipher operation.
nonceLenThe length of the nonce in bytes.
pAadOptional additional authentication data to use.
aadLenLength in bytes of the additional authentication data.
pDataData to decrypt and verify. The tag should be appended to the ciphertext.
dataLenLength in bytes of the data to process. This length does not include the tag.
tagLenLength in bytes of the tag. Must be one of {4,8,12,13,14,15,16}.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_AES_GCM_deleteCtx()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_AES_GCM_deleteCtx ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *  ppCtx)
Parameters
ppCtxLocation holding a pointer to the context to be deleted.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_AES_GCM_encrypt()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_AES_GCM_encrypt ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pNonce,
ubyte4 *  pNonceLen,
intBoolean *  pWasNonceUsed,
ubyte *  pAad,
ubyte4  aadLen,
ubyte *  pData,
ubyte4  dataLen,
ubyte4  tagLen 
)

The underlying implementation may or may not use the nonce that is passed in.

Parameters
pCtxPointer to a context of type AES_GCM_CTX to use for this cipher operation.
pNonceBuffer to hold nonce input to the cipher operation, or buffer that will hold the resulting nonce.
pNonceLenContents should be the length of the nonce passed in, in bytes. If the underlying implementation creates the nonce this will be set to its length in bytes.
pWasNonceUsedContenets will be set to TRUE if the underlying implementation used the nonce passed in and FALSE if it created its own.
pAadOptional additional authentication data to use.
aadLenLength in bytes of the additional authentication data.
pDataData to encrypt and teg. Note for encryption this buffer must be large enough for the output ciphertext and tag.
dataLenLength in bytes of the data to process.
tagLenLength in bytes of the tag. Must be one of {4,8,12,13,14,15,16}.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_AES_GCM_newCtx()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_AES_GCM_newCtx ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *  ppNewCtx,
ubyte4  tableSizeMode,
ubyte *  pKeyMaterial,
sbyte4  keyMaterialLen,
sbyte4  encrypt 
)

It is the callers responsibilty to delete this context after use by calling CRYPTO_INTERFACE_AES_GCM_deleteCtx.

Parameters
ppNewCtxLocation that will recieve a pointer to the newly allocated context.
tableSizeModeThe GCM internal table size, one of the macros GCM_MODE_256B, GCM_MODE_4K, GCM_MODE_64K, GCM_MODE_GENERAL. This must be provided even
pKeyMaterialBuffer holding the key material.
keyMaterialLenLength of the key material in bytes. Should be 16, 24, or 32....
encryptEnter non-zero or TRUE to prepare a context for encrpytion and FALSE for decryption. This is not used for GCM_MODE_GENERAL.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_cipher_256b()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_cipher_256b ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pNonce,
ubyte4  nonceLen,
ubyte *  pAaData,
ubyte4  aadLen,
ubyte *  pData,
ubyte4  dataLen,
ubyte4  tagLen,
sbyte4  encrypt 
)

If all of the data to process is available at one time, this is the recommended function to use. When encrypting, the pData buffer MUST have space for both the data to encrypt and the resulting tag. The tag will be appended to the end of the buffer. When decrypting, this function expects to find a tag of tagLen bytes appended to the pData buffer.


  // Encrypting
  MSTATUS status;
  BulkCtx pCtx = NULL;
  sbyte4 keyLen = 32;
  ubyte4 nonceLen = 12;
  ubyte4 tagLen = 16;
  ubyte4 dataLen = 20;
  ubyte pData[36] = {...}; // Enough space for data + tag
  ubyte pNonce[12] = {...};
  ubyte pKeyData[32] = {...};
  pCtx = CRYPTO_INTERFACE_GCM_createCtx_256b(pKeyData, keyLen, TRUE);
  if (NULL == pCtx)
  {
      status = ERR_NULL_POINTER;
      goto exit;
  }
  // After this call, the pData buffer will contain the 20 bytes of ciphertext
  // followed by a 16 byte tag.
  status = CRYPTO_INTERFACE_GCM_cipher_256b (
      pCtx, pNonce, nonceLen, NULL, 0, pData, dataLen, tagLen, TRUE);
  if (OK != status)
      goto exit;
   // Always delete the context when finished
   status = CRYPTO_INTERFACE_GCM_deleteCtx_256b(&pCtx);
   if (OK != status)
      goto exit;
exit:
  return status;


  // Decrypting
  MSTATUS status;
  BulkCtx pCtx = NULL;
  sbyte4 keyLen = 32;
  ubyte4 nonceLen = 12;
  ubyte4 tagLen = 16;
  ubyte4 dataLen = 20; // Note this is (cipherTextLen - tagLen)
  ubyte pCipherText[36] = {...}; // Start with ciphertext from encryption process
  ubyte pNonce[12] = {...};
  ubyte pKeyData[32] = {...};
  pCtx = CRYPTO_INTERFACE_GCM_createCtx_256b(pKeyData, keyLen, FALSE);
  if (NULL == pCtx)
  {
      status = ERR_NULL_POINTER;
      goto exit;
  }
  // After this call, the pData buffer will contain the 20 bytes of plaintext
  status = CRYPTO_INTERFACE_GCM_cipher_256b (
      pCtx, pNonce, nonceLen, NULL, 0, pData, dataLen, tagLen, FALSE);
  if (OK != status)
      goto exit;
   // Always delete the context when finished
   status = CRYPTO_INTERFACE_GCM_deleteCtx_256b(&pCtx);
   if (OK != status)
      goto exit;
exit:
  return status;

Parameters
pCtxContext to use for this cipher operation.
pNonceThe nonce data to use for this cipher operation.
nonceLenLength in bytes of the nonce material. 12 is the default length.
pAaDataOptional additional authentication data to use.
aadLenLength in bytes of the additional authentication data.
pDataData to encrypt or decrypt. Note for encryption this buffer must be large enough for the output ciphertext and tag.
dataLenLength in bytes of the data to process. When decrypting this value does not include the tag bytes.
tagLenLength in bytes of the tag. Must be one of {4,8,12,13,14,15,16}.
encrypt/c TRUE to encrypt, /c FALSE to decrypt.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_cipher_4k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_cipher_4k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pNonce,
ubyte4  nonceLen,
ubyte *  pAaData,
ubyte4  aadLen,
ubyte *  pData,
ubyte4  dataLen,
ubyte4  tagLen,
sbyte4  encrypt 
)

If all of the data to process is available at one time, this is the recommended function to use. When encrypting, the pData buffer MUST have space for both the data to encrypt and the resulting tag. The tag will be appended to the end of the buffer. When decrypting, this function expects to find a tag of tagLen bytes appended to the pData buffer.


  // Encrypting
  MSTATUS status;
  BulkCtx pCtx = NULL;
  sbyte4 keyLen = 32;
  ubyte4 nonceLen = 12;
  ubyte4 tagLen = 16;
  ubyte4 dataLen = 20;
  ubyte pData[36] = {...}; // Enough space for data + tag
  ubyte pNonce[12] = {...};
  ubyte pKeyData[32] = {...};
  pCtx = CRYPTO_INTERFACE_GCM_createCtx_4k(pKeyData, keyLen, TRUE);
  if (NULL == pCtx)
  {
      status = ERR_NULL_POINTER;
      goto exit;
  }
  // After this call, the pData buffer will contain the 20 bytes of ciphertext
  // followed by a 16 byte tag.
  status = CRYPTO_INTERFACE_GCM_cipher_4k (
      pCtx, pNonce, nonceLen, NULL, 0, pData, dataLen, tagLen, TRUE);
  if (OK != status)
      goto exit;
   // Always delete the context when finished
   status = CRYPTO_INTERFACE_GCM_deleteCtx_4k(&pCtx);
   if (OK != status)
      goto exit;
exit:
  return status;


  // Decrypting
  MSTATUS status;
  BulkCtx pCtx = NULL;
  sbyte4 keyLen = 32;
  ubyte4 nonceLen = 12;
  ubyte4 tagLen = 16;
  ubyte4 dataLen = 20; // Note this is (cipherTextLen - tagLen)
  ubyte pCipherText[36] = {...}; // Start with ciphertext from encryption process
  ubyte pNonce[12] = {...};
  ubyte pKeyData[32] = {...};
  pCtx = CRYPTO_INTERFACE_GCM_createCtx_4k(pKeyData, keyLen, FALSE);
  if (NULL == pCtx)
  {
      status = ERR_NULL_POINTER;
      goto exit;
  }
  // After this call, the pData buffer will contain the 20 bytes of plaintext
  status = CRYPTO_INTERFACE_GCM_cipher_4k (
      pCtx, pNonce, nonceLen, NULL, 0, pData, dataLen, tagLen, FALSE);
  if (OK != status)
      goto exit;
   // Always delete the context when finished
   status = CRYPTO_INTERFACE_GCM_deleteCtx_4k(&pCtx);
   if (OK != status)
      goto exit;
exit:
  return status;

Parameters
pCtxContext to use for this cipher operation.
pNonceThe nonce data to use for this cipher operation.
nonceLenLength in bytes of the nonce material. 12 is the default length.
pAaDataOptional additional authentication data to use.
aadLenLength in bytes of the additional authentication data.
pDataData to encrypt or decrypt. Note for encryption this buffer must be large enough for the output ciphertext and tag.
dataLenLength in bytes of the data to process. When decrypting this value does not include the tag bytes.
tagLenLength in bytes of the tag. Must be one of {4,8,12,13,14,15,16}.
encrypt/c TRUE to encrypt, /c FALSE to decrypt.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_cipher_64k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_cipher_64k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pNonce,
ubyte4  nonceLen,
ubyte *  pAaData,
ubyte4  aadLen,
ubyte *  pData,
ubyte4  dataLen,
ubyte4  tagLen,
sbyte4  encrypt 
)

If all of the data to process is available at one time, this is the recommended function to use. When encrypting, the pData buffer MUST have space for both the data to encrypt and the resulting tag. The tag will be appended to the end of the buffer. When decrypting, this function expects to find a tag of tagLen bytes appended to the pData buffer.


  // Encrypting
  MSTATUS status;
  BulkCtx pCtx = NULL;
  sbyte4 keyLen = 32;
  ubyte4 nonceLen = 12;
  ubyte4 tagLen = 16;
  ubyte4 dataLen = 20;
  ubyte pData[36] = {...}; // Enough space for data + tag
  ubyte pNonce[12] = {...};
  ubyte pKeyData[32] = {...};
  pCtx = CRYPTO_INTERFACE_GCM_createCtx_64k(pKeyData, keyLen, TRUE);
  if (NULL == pCtx)
  {
      status = ERR_NULL_POINTER;
      goto exit;
  }
  // After this call, the pData buffer will contain the 20 bytes of ciphertext
  // followed by a 16 byte tag.
  status = CRYPTO_INTERFACE_GCM_cipher_64k (
      pCtx, pNonce, nonceLen, NULL, 0, pData, dataLen, tagLen, TRUE);
  if (OK != status)
      goto exit;
   // Always delete the context when finished
   status = CRYPTO_INTERFACE_GCM_deleteCtx_64k(&pCtx);
   if (OK != status)
      goto exit;
exit:
  return status;


  // Decrypting
  MSTATUS status;
  BulkCtx pCtx = NULL;
  sbyte4 keyLen = 32;
  ubyte4 nonceLen = 12;
  ubyte4 tagLen = 16;
  ubyte4 dataLen = 20; // Note this is (cipherTextLen - tagLen)
  ubyte pCipherText[36] = {...}; // Start with ciphertext from encryption process
  ubyte pNonce[12] = {...};
  ubyte pKeyData[32] = {...};
  pCtx = CRYPTO_INTERFACE_GCM_createCtx_64k(pKeyData, keyLen, FALSE);
  if (NULL == pCtx)
  {
      status = ERR_NULL_POINTER;
      goto exit;
  }
  // After this call, the pData buffer will contain the 20 bytes of plaintext
  status = CRYPTO_INTERFACE_GCM_cipher_64k (
      pCtx, pNonce, nonceLen, NULL, 0, pData, dataLen, tagLen, FALSE);
  if (OK != status)
      goto exit;
   // Always delete the context when finished
   status = CRYPTO_INTERFACE_GCM_deleteCtx_64k(&pCtx);
   if (OK != status)
      goto exit;
exit:
  return status;

Parameters
pCtxContext to use for this cipher operation.
pNonceThe nonce data to use for this cipher operation.
nonceLenLength in bytes of the nonce material. 12 is the default length.
pAaDataOptional additional authentication data to use.
aadLenLength in bytes of the additional authentication data.
pDataData to encrypt or decrypt. Note for encryption this buffer must be large enough for the output ciphertext and tag.
dataLenLength in bytes of the data to process. When decrypting this value does not include the tag bytes.
tagLenLength in bytes of the tag. Must be one of {4,8,12,13,14,15,16}.
encrypt/c TRUE to encrypt, /c FALSE to decrypt.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_clone_256b()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_clone_256b ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
BulkCtx *  ppNewCtx 
)
Parameters
pCtxPointer to an instantiated BulkCtx.
ppNewCtxDouble pointer to the BulkCtx to be created and populated with the key data from the source key.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_clone_4k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_clone_4k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
BulkCtx *  ppNewCtx 
)
Parameters
pCtxPointer to an instantiated BulkCtx.
ppNewCtxDouble pointer to the BulkCtx to be created and populated with the key data from the source key.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_clone_64k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_clone_64k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
BulkCtx *  ppNewCtx 
)
Parameters
pCtxPointer to an instantiated BulkCtx.
ppNewCtxDouble pointer to the BulkCtx to be created and populated with the key data from the source key.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_createCtx_256b()

MOC_EXTERN BulkCtx CRYPTO_INTERFACE_GCM_createCtx_256b ( MOC_SYM(hwAccelDescr hwAccelCtx) ubyte *  pKeyData,
sbyte4  keyLen,
sbyte4  encrypt 
)

It is the callers responsibilty to delete this context after use by calling CRYPTO_INTERFACE_GCM_deleteCtx_256b.

Parameters
pKeyDataKey material to use.
keyLenLength in bytes of the key material. Must be one of {16, 24, 32}.
encryptTRUE to initialize for encryption, /c FALSE to initialize for decryption.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_createCtx_4k()

MOC_EXTERN BulkCtx CRYPTO_INTERFACE_GCM_createCtx_4k ( MOC_SYM(hwAccelDescr hwAccelCtx) ubyte *  pKeyData,
sbyte4  keyLen,
sbyte4  encrypt 
)

It is the callers responsibilty to delete this context after use by calling CRYPTO_INTERFACE_GCM_deleteCtx_4k.

Parameters
pKeyDataKey material to use.
keyLenLength in bytes of the key material. Must be one of {16, 24, 32}.
encryptTRUE to initialize for encryption, /c FALSE to initialize for decryption.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_createCtx_64k()

MOC_EXTERN BulkCtx CRYPTO_INTERFACE_GCM_createCtx_64k ( MOC_SYM(hwAccelDescr hwAccelCtx) ubyte *  pKeyData,
sbyte4  keyLen,
sbyte4  encrypt 
)

It is the callers responsibilty to delete this context after use by calling CRYPTO_INTERFACE_GCM_deleteCtx_64k.

Parameters
pKeyDataKey material to use.
keyLenLength in bytes of the key material. Must be one of {16, 24, 32}.
encryptTRUE to initialize for encryption, /c FALSE to initialize for decryption.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_deleteCtx_256b()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_deleteCtx_256b ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *  pCtx)
Parameters
pCtxPointer to a BulkCtx returned by CRYPTO_INTERFACE_GCM_createCtx_256b.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_deleteCtx_4k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_deleteCtx_4k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *  pCtx)
Parameters
pCtxPointer to a BulkCtx returned by CRYPTO_INTERFACE_GCM_createCtx_4k.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_deleteCtx_64k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_deleteCtx_64k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx *  pCtx)
Parameters
pCtxPointer to a BulkCtx returned by CRYPTO_INTERFACE_GCM_createCtx_64k.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_final_256b()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_final_256b ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte  pTag[] 
)

In general this should only be used if the caller needs to stream their data to encrypt/decrypt. If all of the data is available at once, using CRYPTO_INTERFACE_GCM_cipher_256b is recommended.

Note that when using this to finalize a decryption operation the caller MUST perform the tag comparison in constant time. Failure to do so could leave the application vulnerable to timing attacks.

Parameters
pCtxContext used for the cipher operation.
pTagBuffer to place the computed tag value.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_final_4k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_final_4k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte  pTag[] 
)

In general this should only be used if the caller needs to stream their data to encrypt/decrypt. If all of the data is available at once, using CRYPTO_INTERFACE_GCM_cipher_4k is recommended.

Note that when using this to finalize a decryption operation the caller MUST perform the tag comparison in constant time. Failure to do so could leave the application vulnerable to timing attacks.

Parameters
pCtxContext used for the cipher operation.
pTagBuffer to place the computed tag value.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_final_64k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_final_64k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte  pTag[] 
)

In general this should only be used if the caller needs to stream their data to encrypt/decrypt. If all of the data is available at once, using CRYPTO_INTERFACE_GCM_cipher_64k is recommended.

Note that when using this to finalize a decryption operation the caller MUST perform the tag comparison in constant time. Failure to do so could leave the application vulnerable to timing attacks.

Parameters
pCtxContext used for the cipher operation.
pTagBuffer to place the computed tag value.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_final_ex_256b()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_final_ex_256b ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pTag,
ubyte4  tagLen 
)

Finalizes an AES-GCM context and verifies or outputs the tag. If the context was created for encryption the tag will be output. If the context was created for decryption the tag will be verified and a negative error code will be returned for an invalid tag.

Parameters
pCtxPointer to a previously allocated and updated context.
pTagFor encrypt the resulting tag will be placed in this buffer. For decrypt this buffer should contain the input tag.
tagLenFor encrypt this is the length of the tag requested in bytes (at most 16 bytes). For decrypt this is the length of the input tag in bytes.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

◆ CRYPTO_INTERFACE_GCM_final_ex_4k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_final_ex_4k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pTag,
ubyte4  tagLen 
)

Finalizes an AES-GCM context and verifies or outputs the tag. If the context was created for encryption the tag will be output. If the context was created for decryption the tag will be verified and a negative error code will be returned for an invalid tag.

Parameters
pCtxPointer to a previously allocated and updated context.
pTagFor encrypt the resulting tag will be placed in this buffer. For decrypt this buffer should contain the input tag.
tagLenFor encrypt this is the length of the tag requested in bytes (at most 16 bytes). For decrypt this is the length of the input tag in bytes.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

◆ CRYPTO_INTERFACE_GCM_final_ex_64k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_final_ex_64k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pTag,
ubyte4  tagLen 
)

Finalizes an AES-GCM context and verifies or outputs the tag. If the context was created for encryption the tag will be output. If the context was created for decryption the tag will be verified and a negative error code will be returned for an invalid tag.

Parameters
pCtxPointer to a previously allocated and updated context.
pTagFor encrypt the resulting tag will be placed in this buffer. For decrypt this buffer should contain the input tag.
tagLenFor encrypt this is the length of the tag requested in bytes (at most 16 bytes). For decrypt this is the length of the input tag in bytes.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

◆ CRYPTO_INTERFACE_GCM_init_256b()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_init_256b ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pNonce,
ubyte4  nonceLen,
ubyte *  pAaData,
ubyte4  aadLen 
)
Parameters
pCtxContext returned by CRYPTO_INTERFACE_GCM_createCtx_256b.
pNonceThe nonce to use for this operation.
nonceLenLength in bytes of the nonce material.
pAaDataOptional additional authentication data.
aadLenLength in bytes of the additional authentication data.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_init_4k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_init_4k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pNonce,
ubyte4  nonceLen,
ubyte *  pAaData,
ubyte4  aadLen 
)
Parameters
pCtxContext returned by CRYPTO_INTERFACE_GCM_createCtx_4k.
pNonceThe nonce to use for this operation.
nonceLenLength in bytes of the nonce material.
pAaDataOptional additional authentication data.
aadLenLength in bytes of the additional authentication data.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_init_64k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_init_64k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pNonce,
ubyte4  nonceLen,
ubyte *  pAaData,
ubyte4  aadLen 
)
Parameters
pCtxContext returned by CRYPTO_INTERFACE_GCM_createCtx_64k.
pNonceThe nonce to use for this operation.
nonceLenLength in bytes of the nonce material.
pAaDataOptional additional authentication data.
aadLenLength in bytes of the additional authentication data.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_update_aad_256b()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_aad_256b ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pAadData,
ubyte4  aadDataLen 
)

Updates an AES-GCM context with additional authenticated data. This method may be called as many times as necessary.

Parameters
pCtxPointer to a previously allocated context.
pAadDataBuffer holding the additional authenticated data.
aadDataLenThe length of the aad in bytes.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

◆ CRYPTO_INTERFACE_GCM_update_aad_4k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_aad_4k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pAadData,
ubyte4  aadDataLen 
)

Updates an AES-GCM context with additional authenticated data. This method may be called as many times as necessary.

Parameters
pCtxPointer to a previously allocated context.
pAadDataBuffer holding the additional authenticated data.
aadDataLenThe length of the aad in bytes.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

◆ CRYPTO_INTERFACE_GCM_update_aad_64k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_aad_64k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pAadData,
ubyte4  aadDataLen 
)

Updates an AES-GCM context with additional authenticated data. This method may be called as many times as necessary.

Parameters
pCtxPointer to a previously allocated context.
pAadDataBuffer holding the additional authenticated data.
aadDataLenThe length of the aad in bytes.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

◆ CRYPTO_INTERFACE_GCM_update_data_256b()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_data_256b ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pData,
ubyte4  dataLen 
)

Updates an AES-GCM context with data to be encrypted or decrypted. Which direction depends on the encrypt flag passed into the context creation GCM_createCtx_64k method. The GCM_update_data_64k method may be called as many times as necessary.

Parameters
pCtxPointer to a previously allocated context.
pDataBuffer holding the data to be encrypted or decrypted. It will be processed in place, ie this buffer will also hold the resulting ciphertext or plaintext.
dataLenThe length of the data in bytes.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

◆ CRYPTO_INTERFACE_GCM_update_data_4k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_data_4k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pData,
ubyte4  dataLen 
)

Updates an AES-GCM context with data to be encrypted or decrypted. Which direction depends on the encrypt flag passed into the context creation GCM_createCtx_64k method. The GCM_update_data_64k method may be called as many times as necessary.

Parameters
pCtxPointer to a previously allocated context.
pDataBuffer holding the data to be encrypted or decrypted. It will be processed in place, ie this buffer will also hold the resulting ciphertext or plaintext.
dataLenThe length of the data in bytes.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

◆ CRYPTO_INTERFACE_GCM_update_data_64k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_data_64k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pData,
ubyte4  dataLen 
)

Updates an AES-GCM context with data to be encrypted or decrypted. Which direction depends on the encrypt flag passed into the context creation GCM_createCtx_64k method. The GCM_update_data_64k method may be called as many times as necessary.

Parameters
pCtxPointer to a previously allocated context.
pDataBuffer holding the data to be encrypted or decrypted. It will be processed in place, ie this buffer will also hold the resulting ciphertext or plaintext.
dataLenThe length of the data in bytes.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

◆ CRYPTO_INTERFACE_GCM_update_decrypt_256b()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_decrypt_256b ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pCipherText,
ubyte4  cipherTextLen 
)

Note that AES-GCM is a stream cipher so both the overall input length and the input length to any one update call does not need to be a multiple of the AES block size. This function operates on data in place, so the resulting ciphertext will be in the provided data buffer after the encryption process is complete.

Parameters
pCtxContext to use for the encryption operation.
pCipherTextData to encrypt.
cipherTextLenLength in bytes of the data to encrypt.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_update_decrypt_4k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_decrypt_4k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pCipherText,
ubyte4  cipherTextLen 
)

Note that AES-GCM is a stream cipher so both the overall input length and the input length to any one update call does not need to be a multiple of the AES block size. This function operates on data in place, so the resulting ciphertext will be in the provided data buffer after the encryption process is complete.

Parameters
pCtxContext to use for the encryption operation.
pCipherTextData to encrypt.
cipherTextLenLength in bytes of the data to encrypt.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_update_decrypt_64k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_decrypt_64k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pCipherText,
ubyte4  cipherTextLen 
)

Note that AES-GCM is a stream cipher so both the overall input length and the input length to any one update call does not need to be a multiple of the AES block size. This function operates on data in place, so the resulting ciphertext will be in the provided data buffer after the encryption process is complete.

Parameters
pCtxContext to use for the encryption operation.
pCipherTextData to encrypt.
cipherTextLenLength in bytes of the data to encrypt.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_update_encrypt_256b()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_encrypt_256b ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pData,
ubyte4  dataLen 
)

Note that AES-GCM is a stream cipher so both the overall input length and the input length to any one update call does not need to be a multiple of the AES block size. This function operates on data in place, so the resulting ciphertext will be in the provided data buffer after the encryption process is complete.

Parameters
pCtxContext to use for the encryption operation.
pDataData to encrypt.
dataLenLength in bytes of the data to encrypt.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_update_encrypt_4k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_encrypt_4k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pData,
ubyte4  dataLen 
)

Note that AES-GCM is a stream cipher so both the overall input length and the input length to any one update call does not need to be a multiple of the AES block size. This function operates on data in place, so the resulting ciphertext will be in the provided data buffer after the encryption process is complete.

Parameters
pCtxContext to use for the encryption operation.
pDataData to encrypt.
dataLenLength in bytes of the data to encrypt.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_update_encrypt_64k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_encrypt_64k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pData,
ubyte4  dataLen 
)

Note that AES-GCM is a stream cipher so both the overall input length and the input length to any one update call does not need to be a multiple of the AES block size. This function operates on data in place, so the resulting ciphertext will be in the provided data buffer after the encryption process is complete.

Parameters
pCtxContext to use for the encryption operation.
pDataData to encrypt.
dataLenLength in bytes of the data to encrypt.
Returns
OK (0) if successful, otherwise a negative number error code from merrors.h.

◆ CRYPTO_INTERFACE_GCM_update_nonce_256b()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_nonce_256b ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pNonce,
ubyte4  nonceLen 
)

Sets the nonce in a previously created AES-GCM Context.

Parameters
pCtxPointer to a previously allocated context.
pNonceBuffer holding the input nonce value.
nonceLenThe length of the nonce in bytes.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

◆ CRYPTO_INTERFACE_GCM_update_nonce_4k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_nonce_4k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pNonce,
ubyte4  nonceLen 
)

Sets the nonce in a previously created AES-GCM Context.

Parameters
pCtxPointer to a previously allocated context.
pNonceBuffer holding the input nonce value.
nonceLenThe length of the nonce in bytes.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.

◆ CRYPTO_INTERFACE_GCM_update_nonce_64k()

MOC_EXTERN MSTATUS CRYPTO_INTERFACE_GCM_update_nonce_64k ( MOC_SYM(hwAccelDescr hwAccelCtx) BulkCtx  pCtx,
ubyte *  pNonce,
ubyte4  nonceLen 
)

Sets the nonce in a previously created AES-GCM Context.

Parameters
pCtxPointer to a previously allocated context.
pNonceBuffer holding the input nonce value.
nonceLenThe length of the nonce in bytes.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.