MCUX CLNS MCUX Crypto Library Normal Secure |

Functions
mcuxClCss_Cipher_Functions
mcuxClCss » mcuxClCss_Cipher

Defines all functions of mcuxClCss_Cipher. More...

## Functions

MCUXCLCSS_API mcuxClCss_Status_Protected_t | mcuxClCss_Cipher_Async (mcuxClCss_CipherOption_t options, mcuxClCss_KeyIndex_t keyIdx, uint8_t const *pKey, size_t keyLength, uint8_t const *pInput, size_t inputLength, uint8_t *pIV, uint8_t *pOutput)
| Performs AES encryption/decryption. More...

## Detailed Description

Defines all functions of mcuxClCss_Cipher.

## Function Documentation

## ◆ mcuxClCss_Cipher_Async()

MCUXCLCSS_API mcuxClCss_Status_Protected_t mcuxClCss_Cipher_Async | ( | mcuxClCss_CipherOption_t | options,
|  | mcuxClCss_KeyIndex_t | keyIdx,
|  | uint8_t const * | pKey,
|  | size_t | keyLength,
|  | uint8_t const * | pInput,
|  | size_t | inputLength,
|  | uint8_t * | pIV,
|  | uint8_t * | pOutput
| ) |  |

Performs AES encryption/decryption.

Performs an AES encryption/decryption. Call mcuxClCss_WaitForOperation to complete the operation.

Parameters

  [in] | options | Encryption/decryption command options. For detailed information, see mcuxClCss_CipherOption_t.
  [in] | keyIdx | Index of the key inside the CSSv2 keystore. See parameter properties section in function description.
  [in] | pKey | Memory area that contains the key. See parameter properties section in function description.
  [in] | keyLength | Size of `pKey` in bytes. Must be a valid key size of MCUXCLCSS_CIPHER_KEY_SIZE_AES_. See parameter properties section in function description.
  [in] | pInput | Pointer to the input data to be encrypted/decrypted. Padding must be already applied.
  [in] | inputLength | Size of `pInput` in bytes, must be a multiple of the block size.
  [in,out] | pIV | A pointer to the memory location which contains/receives the IV/state of cipher. See parameter properties section in function description.
  [out] | pOutput | Pointer to the output buffer to store encrypted/decrypted data.

The properties of some parameters change with respect to selected options.

Parameter properties
  `options.cphmde` == MCUXCLCSS_CIPHERPARAM_ALGORITHM_AES_ECB

    `pIV` is ignored.

  `options.cphmde` == MCUXCLCSS_CIPHERPARAM_ALGORITHM_AES_CBC

    `pIV` must be set to the IV (when encrypting the first block) or to the last block of the ciphertext of the previous operation. CSSv2 will always read and write to this location.

    `options.cphsie` is ignored.

             @p options.cphsoe is ignored.</dd>

         <dt>@p options.cphmde == #MCUXCLCSS_CIPHERPARAM_ALGORITHM_AES_CTR</dt>
             <dd>@p pIV must be set to the IV (when encrypting the first block) or to the state output of the previous
             encryption/decryption operation. CSSv2 will write to this location if @p options.cphsoe == #MCUXCLCSS_CIPHER_STATE_OUT_ENABLE.</dd>

         <dt>@p options.extkey == #MCUXCLCSS_CIPHER_EXTERNAL_KEY</dt>
             <dd>@p keyIdx is ignored.</dd>

         <dt>@p options.extkey == #MCUXCLCSS_CIPHER_INTERNAL_KEY</dt>
             <dd>@p pKey is ignored.

             @p keyLength is ignored.</dd>

Returns
  An error code that can be any error code in MCUXCLCSS_STATUS_, see individual documentation for more information

Return values

  MCUXCLCSS_STATUS_SW_INVALID_PARAM | if invalid parameters were specified
  MCUXCLCSS_STATUS_SW_CANNOT_INTERRUPT | if a running operation prevented the request
  MCUXCLCSS_STATUS_OK_WAIT | on successful request

Examples
  cipher_aes128_cbc_encrypt.c, and cipher_aes128_ecb_encrypt.c.