NXP Reader Library  v17.1.0.2535

Symmetric Crypto Command of HAL DUT Command dispatcher frame. More...

Collaboration diagram for Command_CryptoSym:

Modules

 Command_Codes
 Symmetric Crypto Command Codes of HAL DUT Command dispatcher frame.
 
 Defines
 Symmetric Crypto Definitions of HAL DUT Command dispatcher frame.
 

Functions

phStatus_t phhalHw_DUT_Cmd_CryptoSym_Init (phhalHw_DUT_DataParams_t *pDataParams)
 Initialize Hardware Symmetric Crypto Component. More...
 
phStatus_t phhalHw_DUT_Cmd_CryptoSym_DeInit (phhalHw_DUT_DataParams_t *pDataParams)
 Un-Initialize Hardware Symmetric Crypto Component. More...
 
phStatus_t phhalHw_DUT_Cmd_CryptoSym_GetLastStatus (phhalHw_DUT_DataParams_t *pDataParams, uint16_t wStatusMsgLen, int8_t *pStatusMsg, int32_t *pStatusCode)
 Returns the status code and respective message. More...
 
phStatus_t phhalHw_DUT_Cmd_CryptoSym_InvalidateKey (phhalHw_DUT_DataParams_t *pDataParams)
 Invalidate the currently loaded key. More...
 
phStatus_t phhalHw_DUT_Cmd_CryptoSym_SetConfig (phhalHw_DUT_DataParams_t *pDataParams, uint16_t wConfig, uint16_t wValue)
 Set configuration parameter. More...
 
phStatus_t phhalHw_DUT_Cmd_CryptoSym_GetConfig (phhalHw_DUT_DataParams_t *pDataParams, uint16_t wConfig, uint16_t *pValue)
 Get configuration parameter. More...
 
phStatus_t phhalHw_DUT_Cmd_CryptoSym_Encrypt (phhalHw_DUT_DataParams_t *pDataParams, uint16_t wOption, const uint8_t *pPlainBuff, uint16_t wBuffLen, uint8_t *pEncBuff)
 Perform Encryption with one of the supported crypto modes. More...
 
phStatus_t phhalHw_DUT_Cmd_CryptoSym_Decrypt (phhalHw_DUT_DataParams_t *pDataParams, uint16_t wOption, const uint8_t *pEncBuff, uint16_t wBuffLen, uint8_t *pPlainBuff)
 Perform Decryption with one of the supported crypto modes. More...
 
phStatus_t phhalHw_DUT_Cmd_CryptoSym_CalculateMac (phhalHw_DUT_DataParams_t *pDataParams, uint16_t wOption, const uint8_t *pData, uint16_t wDataLen, uint8_t *pMac, uint8_t *pMacLen)
 Calculate MAC with one of the supported MAC modes. More...
 
phStatus_t phhalHw_DUT_Cmd_CryptoSym_LoadIv (phhalHw_DUT_DataParams_t *pDataParams, const uint8_t *pIV, uint8_t bIVLen)
 Load IV. More...
 
phStatus_t phhalHw_DUT_Cmd_CryptoSym_LoadKey (phhalHw_DUT_DataParams_t *pDataParams, uint16_t wKeyNo, uint16_t wKeyVer, uint16_t wKeyType)
 Load Key. More...
 
phStatus_t phhalHw_DUT_Cmd_CryptoSym_LoadKeyDirect (phhalHw_DUT_DataParams_t *pDataParams, const uint8_t *pKey, uint16_t wKeyType)
 Direct Load Key. More...
 
phStatus_t phhalHw_DUT_Cmd_CryptoSym_DiversifyKey (phhalHw_DUT_DataParams_t *pDataParams, uint16_t wOption, uint16_t wKeyNo, uint16_t wKeyVer, uint8_t *pDivInput, uint8_t bDivInLen, uint8_t *pDivKey, uint8_t *pDivKeyLen)
 Diversify Key - Note: This function invalidates the currently loaded key. More...
 
phStatus_t phhalHw_DUT_Cmd_CryptoSym_DiversifyDirectKey (phhalHw_DUT_DataParams_t *pDataParams, uint16_t wOption, uint8_t *pKey, uint16_t wKeyType, uint8_t *pDivInput, uint8_t bDivInLen, uint8_t *pDivKey, uint8_t *pDivKeyLen)
 Diversify Direct Key - Note: This function invalidates the currently loaded key. More...
 

Detailed Description

Symmetric Crypto Command of HAL DUT Command dispatcher frame.

Function Documentation

◆ phhalHw_DUT_Cmd_CryptoSym_Init()

phStatus_t phhalHw_DUT_Cmd_CryptoSym_Init ( phhalHw_DUT_DataParams_t pDataParams)

Initialize Hardware Symmetric Crypto Component.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.

◆ phhalHw_DUT_Cmd_CryptoSym_DeInit()

phStatus_t phhalHw_DUT_Cmd_CryptoSym_DeInit ( phhalHw_DUT_DataParams_t pDataParams)

Un-Initialize Hardware Symmetric Crypto Component.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.

◆ phhalHw_DUT_Cmd_CryptoSym_GetLastStatus()

phStatus_t phhalHw_DUT_Cmd_CryptoSym_GetLastStatus ( phhalHw_DUT_DataParams_t pDataParams,
uint16_t  wStatusMsgLen,
int8_t pStatusMsg,
int32_t pStatusCode 
)

Returns the status code and respective message.

This interfaces is supported only if CryptoSym component is initialized with mBedTLS Initialization.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wStatusMsgLen[In] Size of bytes allocated for pStatusMsg parameter.
[out]pStatusMsg[Out] The equivalent status message for the information available in pStatusCode.
[out]pStatusCode[Out] The status code returned by the underlying Crypto library.

◆ phhalHw_DUT_Cmd_CryptoSym_InvalidateKey()

phStatus_t phhalHw_DUT_Cmd_CryptoSym_InvalidateKey ( phhalHw_DUT_DataParams_t pDataParams)

Invalidate the currently loaded key.

Resets the key, the IV, the keep IV flag and the key Type.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.

◆ phhalHw_DUT_Cmd_CryptoSym_SetConfig()

phStatus_t phhalHw_DUT_Cmd_CryptoSym_SetConfig ( phhalHw_DUT_DataParams_t pDataParams,
uint16_t  wConfig,
uint16_t  wValue 
)

Set configuration parameter.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_INVALID_DATA_PARAMS
  • If the interface context (pDataparams) is not holding this layer ID.
  • If the component context holds a different sub-component ID that is not supported by this layer.
PH_ERR_INVALID_PARAMETERValid wConfig but invalid wValue for that config.
PH_ERR_UNSUPPORTED_PARAMETERInvalid (Unsupported) wConfig.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wConfig[In] Configuration Identifier. Refer Configuration Identifier
[in]wValue[In] Configuration Value for the provided configuration identifier. Refer KeepIV Options for PHHAL_HW_DUT_CMD_CRYPTOSYM_CONFIG_KEEP_IV configuration identifier.

◆ phhalHw_DUT_Cmd_CryptoSym_GetConfig()

phStatus_t phhalHw_DUT_Cmd_CryptoSym_GetConfig ( phhalHw_DUT_DataParams_t pDataParams,
uint16_t  wConfig,
uint16_t pValue 
)

Get configuration parameter.

Return values
PH_ERR_INVALID_DATA_PARAMS
  • If the interface context (pDataparams) is not holding this layer ID.
  • If the component context holds a different sub-component ID that is not supported by this layer.
PH_ERR_INVALID_PARAMETERValue behind wConfig not valid at the moment.
PH_ERR_UNSUPPORTED_PARAMETERInvalid (Unsupported) wConfig.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wConfig[In] Configuration Identifier. Refer Configuration Identifier
[out]pValue[Out] Configuration Value for the provided configuration identifier.

◆ phhalHw_DUT_Cmd_CryptoSym_Encrypt()

phStatus_t phhalHw_DUT_Cmd_CryptoSym_Encrypt ( phhalHw_DUT_DataParams_t pDataParams,
uint16_t  wOption,
const uint8_t pPlainBuff,
uint16_t  wBuffLen,
uint8_t pEncBuff 
)

Perform Encryption with one of the supported crypto modes.

The option word specifies the operation mode to use and the update behavior of the IV. All modes of operation are coded in the LSB, the flags in the MSB. The following Cipher modes are supported:

The following Flags are supported:

Note: The input data length needs to be a multiple of the current block size

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_INVALID_DATA_PARAMS
  • If the interface context (pDataparams) is not holding this layer ID.
  • If the component context holds a different sub-component ID that is not supported by this layer.
PH_ERR_INVALID_PARAMETERAn unsupported key is loaded (or no key is loaded) or wBufferLength is not a multiple of the current block size.
PH_ERR_UNSUPPORTED_PARAMETERAn unknown cipher option wOption is specified.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wOption[In] Option byte specifying the cipher mode and the update behavior of the IV
[in]pPlainBuff[In] Plain data buffer.
  • Should always be in multiple of current block size.
  • If not of current block size then Padding needs to be applied to make it upto current block size.
[in]wBuffLen[In] Length of plain and encrypted data buffer - needs to be a multiple of the current block size
[out]pEncBuff[Out] Encrypted data buffer. Will always be in multiple of current block size.

◆ phhalHw_DUT_Cmd_CryptoSym_Decrypt()

phStatus_t phhalHw_DUT_Cmd_CryptoSym_Decrypt ( phhalHw_DUT_DataParams_t pDataParams,
uint16_t  wOption,
const uint8_t pEncBuff,
uint16_t  wBuffLen,
uint8_t pPlainBuff 
)

Perform Decryption with one of the supported crypto modes.

The option word specifies the operation mode to use and the update behavior of the IV. All modes of operation are coded in the LSB, the flags in the MSB. The following Cipher modes are supported:

The following Flags are supported:

Note: The input data length needs to be a multiple of the current block size

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_INVALID_DATA_PARAMS
  • If the interface context (pDataparams) is not holding this layer ID.
  • If the component context holds a different sub-component ID that is not supported by this layer.
PH_ERR_INVALID_PARAMETERAn unsupported key is loaded (or no key is loaded) or wBufferLength is not a multiple of the current block size.
PH_ERR_UNSUPPORTED_PARAMETERAn unknown cipher option wOption is specified.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wOption[In] Option byte specifying the cipher mode and the update behavior of the IV
[in]pEncBuff[In] Encrypted data buffer. Should always be in multiple of current block size.
[in]wBuffLen[In] Length of plain and encrypted data buffer - needs to be a multiple of the current block size.
[out]pPlainBuff[Out] Plain data buffer. Will always be in multiple of current block size. Plain data may be padded with zeros if not current block size.

◆ phhalHw_DUT_Cmd_CryptoSym_CalculateMac()

phStatus_t phhalHw_DUT_Cmd_CryptoSym_CalculateMac ( phhalHw_DUT_DataParams_t pDataParams,
uint16_t  wOption,
const uint8_t pData,
uint16_t  wDataLen,
uint8_t pMac,
uint8_t pMacLen 
)

Calculate MAC with one of the supported MAC modes.

The option word specifies the MAC mode to use and the update behavior of the IV as well as the completion behavior. All modes of operation are coded in the LSB, the flags in the MSB. The following Cipher modes are supported:

The following Flags are supported:

Note: If PH_EXCHANGE_BUFFERED_BIT is set, the input length needs to be a multiple of the block length!

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_INVALID_DATA_PARAMS
  • If the interface context (pDataparams) is not holding this layer ID.
  • If the component context holds a different sub-component ID that is not supported by this layer.
PH_ERR_INVALID_PARAMETERAn unsupported key is loaded (or no key is loaded) or wDataLength is not a multiple of the current block size and the option PH_EXCHANGE_BUFFERED_BIT is set.
PH_ERR_UNSUPPORTED_PARAMETERAn unknown mac option wOption is specified.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wOption[In] Option byte specifying the MAC mode and the update behavior of the IV and the completion flag.
[in]pData[In] Input data on which the MAC needs to be computed. Input will be always be in multiple of current block size if wOption is
[in]wDataLen[In] number of input data bytes
[out]pMac[Out] Output MAC block; uint8_t[16]
[out]pMacLen[Out] Length of MAC

◆ phhalHw_DUT_Cmd_CryptoSym_LoadIv()

phStatus_t phhalHw_DUT_Cmd_CryptoSym_LoadIv ( phhalHw_DUT_DataParams_t pDataParams,
const uint8_t pIV,
uint8_t  bIVLen 
)

Load IV.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_INVALID_DATA_PARAMS
  • If the interface context (pDataparams) is not holding this layer ID.
  • If the component context holds a different sub-component ID that is not supported by this layer.
PH_ERR_INVALID_PARAMETERbIVLength does not match the current block size.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]pIV[In] Initialization vector to use. Should of current block size.
[in]bIVLen[In] Length of bytes available in pIV buffer.

◆ phhalHw_DUT_Cmd_CryptoSym_LoadKey()

phStatus_t phhalHw_DUT_Cmd_CryptoSym_LoadKey ( phhalHw_DUT_DataParams_t pDataParams,
uint16_t  wKeyNo,
uint16_t  wKeyVer,
uint16_t  wKeyType 
)

Load Key.

This function uses the key storage provided at component initialization to retrieve the key identified by wKeyNo and wKeyVersion. After retrieving the key is loaded into the internal key storage array to be prepared for subsequent cipher operations.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_INVALID_DATA_PARAMS
  • If the interface context (pDataparams) is not holding this layer ID.
  • If the component context holds a different sub-component ID that is not supported by this layer.
  • No KeyStore specified at initialization.
PH_ERR_UNSUPPORTED_PARAMETERKey Type not supported.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wKeyNo[In] Key number in KeyStore to be loaded.
[in]wKeyVer[In] Key Version in KeyStore to be loaded.
[in]wKeyType[In] Type of Key to be loaded. Supported ones are

◆ phhalHw_DUT_Cmd_CryptoSym_LoadKeyDirect()

phStatus_t phhalHw_DUT_Cmd_CryptoSym_LoadKeyDirect ( phhalHw_DUT_DataParams_t pDataParams,
const uint8_t pKey,
uint16_t  wKeyType 
)

Direct Load Key.

The key provided in the pKey parameter is loaded into the internal key storage array to be prepared for subsequent cipher operations.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_INVALID_DATA_PARAMS
  • If the interface context (pDataparams) is not holding this layer ID.
  • If the component context holds a different sub-component ID that is not supported by this layer.
PH_ERR_UNSUPPORTED_PARAMETERKey Type not supported.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]pKey[In] Key to be loaded. Number of bytes should be based on the key type mentioned in wKeyType parameter.
[in]wKeyType[In] Type of Key to be loaded. Supported ones are

◆ phhalHw_DUT_Cmd_CryptoSym_DiversifyKey()

phStatus_t phhalHw_DUT_Cmd_CryptoSym_DiversifyKey ( phhalHw_DUT_DataParams_t pDataParams,
uint16_t  wOption,
uint16_t  wKeyNo,
uint16_t  wKeyVer,
uint8_t pDivInput,
uint8_t  bDivInLen,
uint8_t pDivKey,
uint8_t pDivKeyLen 
)

Diversify Key - Note: This function invalidates the currently loaded key.

Using the key stored in the KeyStore passed at initialization of the component and identified by wKeyNo and wKeyVersion this function calculates a diversified key according to the wOption specified that can be used in different applications.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_INVALID_DATA_PARAMS
  • If the interface context (pDataparams) is not holding this layer ID.
  • If the component context holds a different sub-component ID that is not supported by this layer.
  • No KeyStore specified at Initialization.
PH_ERR_UNSUPPORTED_PARAMETERKey Type not supported (for key diversification).
PH_ERR_LENGTH_ERRORLength of diversification input is wrong.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wOption[In] Option to specify the diversification method. One of the below mentioned information.
[in]wKeyNo[In] Key number in KeyStore to be loaded
[in]wKeyVer[In] Key Version in KeyStore to be loaded
[in]pDivInput[In] Diversification Input used to diversify the key.
[in]bDivInLen[In] Length of diversification input used to diversify the key. If 0, no diversification is performed.
[out]pDivKey[Out] Diversified key. Will be of current block size.
[out]pDivKeyLen[Out] Length of bytes available in pDivKey buffer.

◆ phhalHw_DUT_Cmd_CryptoSym_DiversifyDirectKey()

phStatus_t phhalHw_DUT_Cmd_CryptoSym_DiversifyDirectKey ( phhalHw_DUT_DataParams_t pDataParams,
uint16_t  wOption,
uint8_t pKey,
uint16_t  wKeyType,
uint8_t pDivInput,
uint8_t  bDivInLen,
uint8_t pDivKey,
uint8_t pDivKeyLen 
)

Diversify Direct Key - Note: This function invalidates the currently loaded key.

Using the key passed in the pKey parameter this function calculates a diversified key according to the wOption specified that can be used in different applications.

Returns
Status code
Return values
PH_ERR_SUCCESSOperation successful.
PH_ERR_INVALID_DATA_PARAMS
  • If the interface context (pDataparams) is not holding this layer ID.
  • If the component context holds a different sub-component ID that is not supported by this layer.
PH_ERR_UNSUPPORTED_PARAMETERKey Type not supported (for key diversification).
PH_ERR_LENGTH_ERRORLength of diversification input is wrong.
OtherDepending on implementation and underlying component.
Parameters
[in]pDataParams[In] Pointer to this layer's parameter structure.
[in]wOption[In] Option to specify the diversification method. One of the below mentioned information.
[in]pKey[In] Key to be loaded. Number of bytes should be based on the key type mentioned in wKeyType parameter.
[in]wKeyType[In] Type of Key to be loaded. Supported ones are
[in]pDivInput[In] Diversification Input used to diversify the key.
[in]bDivInLen[In] Length of diversification input used to diversify the key. If 0, no diversification is performed.
[out]pDivKey[Out] Diversified key. Will be of current block size.
[out]pDivKeyLen[Out] Length of bytes available in pDivKey buffer.