/* * * Copyright 2018,2019 NXP * SPDX-License-Identifier: Apache-2.0 */ #ifndef _FSL_SSCP_MU_H_ #define _FSL_SSCP_MU_H_ //#include "fsl_mu.h" #include "fsl_sscp.h" typedef uint32_t MU_Type; /*! @defgroup sscp_mu SSCP over MU @details This section describes definition of the messages for the MU to invoke services and MU implementation specific functions to initialize SSCP MU link, deinitialize SSCP MU link and MU invoke command. @ingroup sscp # MU commands ## Symmetric cipher ### Symmetric cipher in one go @copydetails sss_cipher_one_go
Symmetric Cipher One Go TX MU TXn register value
Command 0 kSSCP_CMD_SSS_SymmetricCipherOneGo
paramTypes 1 Context, MemrefInput, MemrefInput, MemrefOutput
word 2 Pointer to ::_sss_sscp_symmetric
word 3 Pointer to iv
word 4 ivLen
word 5 Pointer to srcData
word 6 dataLen
word 7 Pointer to destData
word 8 Pointer to dataLen
### Symmetric AES in counter mode @copydetails sss_cipher_crypt_ctr
AES in Counter Mode TX MU TXn register value
Command 0 kSSCP_CMD_SSS_SymmetricCryptCtr
paramTypes 1 Context, MemrefInput, MemrefOutput, MemrefInOut, MemrefInOut, MemrefInOut
word 2 Pointer to ::_sss_sscp_symmetric
word 3 Pointer to input data buffer
word 4 Length of the input data buffer in bytes
word 5 Pointer to output data buffer
word 6 Pointer to uint32_t with length of the output data buffer in bytes
word 7 Pointer to Initial Counter Block
word 8 Length of the Initial Counter Block in bytes
word 9 Pointer to Last Encrypted Counter Block
word 10 Length of the Last Encrypted Counter Block in bytes
word 11 Pointer to uint32_t specifying number of bytes left unused in the Last Encrypted Counter Block
word 12 sizeof(uint32_t)
### Authenticated encryption with additional data @copydetails sss_aead_one_go
Authenticated Encryption with Additional Data TX MU TXn register value
Command 0 kSSCP_CMD_SSS_AeadOneGo
paramTypes 1 Context, MemrefInput, MemrefOutput, MemrefOutput, MemrefInput, MemrefInput, MemrefOutput
word 2 Pointer to ::_sss_sscp_aead
word 3 Pointer to input data buffer
word 4 Length of the input data buffer in bytes
word 5 Pointer to output data buffer
word 6 Pointer to uint32_t with length of the output data buffer in bytes
word 7 Pointer to nonce buffer
word 8 Length of the nonce buffer in bytes
word 9 Pointer to aad buffer
word 10 Length of the aad buffer in bytes
word 11 Pointer to tag buffer
word 12 Pointer to uint32_t with length of the tag buffer in bytes
## Digest ### Message digest in one go @copydetails sss_digest_one_go
Digest One Go TX MU TXn register value
Command 0 kSSCP_CMD_SSS_DigestOneGo
paramTypes 1 Context, MemrefInput, MemrefOutput
word 2 Pointer to ::_sss_sscp_digest
word 3 Pointer to message
word 4 messageLen
word 5 Pointer to digest
word 6 Pointer to digestLen
### Message digest init @copydetails sss_digest_init
Digest Init TX MU TXn register value
Command 0 kSSCP_CMD_SSS_DigestInit
paramTypes 1 Context
word 2 Pointer to ::_sss_sscp_digest
### Message digest update @copydetails sss_digest_update
Digest Update TX MU TXn register value
Command 0 kSSCP_CMD_SSS_DigestUpdate
paramTypes 1 Context, MemrefInput
word 2 Pointer to ::_sss_sscp_digest
word 3 Pointer to message
word 4 messageLen
### Message digest finish @copydetails sss_digest_finish
Digest Finish TX MU TXn register value
Command 0 kSSCP_CMD_SSS_DigestFinish
paramTypes 1 Context, MemrefOutput
word 2 Pointer to ::_sss_sscp_digest
word 3 Pointer to digest
word 4 Pointer to digestLen
## Mac ### Message authentication code (MAC) in one go @copydetails sss_mac_one_go
Mac One Go TX MU TXn register value
Command 0 kSSCP_CMD_SSS_MacOneGo
paramTypes 1 Context, MemrefInput, MemrefOutput
word 2 Pointer to ::_sss_sscp_mac
word 3 Pointer to message
word 4 messageLen
word 5 Pointer to mac
word 6 Pointer to macLen
### Message mac init @copydetails sss_mac_init
Mac Init TX MU TXn register value
Command 0 kSSCP_CMD_SSS_MacInit
paramTypes 1 Context
word 2 Pointer to ::_sss_sscp_mac
### Message mac update @copydetails sss_mac_update
Mac Update TX MU TXn register value
Command 0 kSSCP_CMD_SSS_MacUpdate
paramTypes 1 Context, MemrefInput
word 2 Pointer to ::_sss_sscp_mac
word 3 Pointer to message
word 4 messageLen
### Message mac finish @copydetails sss_mac_finish
MAc Finish TX MU TXn register value
Command 0 kSSCP_CMD_SSS_MacFinish
paramTypes 1 Context, MemrefOutput
word 2 Pointer to ::_sss_sscp_mac
word 3 Pointer to mac
word 4 Pointer to macLen
## Asymmetric ### Asymmetric sign digest @copydetails sss_asymmetric_sign_digest
Asymmetric Sign Digest TX MU TXn register value
Command 0 kSSCP_CMD_SSS_AsymmetricSignDigest
paramTypes 1 Context, MemrefInput, MemrefOutput
word 2 Pointer to ::_sss_sscp_asymmetric
word 3 Pointer to digest
word 4 digestLen
word 5 Pointer to signature
word 6 Pointer to signatureLen
### Asymmetric verify digest @copydetails sss_asymmetric_verify_digest
Asymmetric Verify Digest TX MU TXn register value
Command 0 kSSCP_CMD_SSS_AsymmetricVerifyDigest
paramTypes 1 Context, MemrefInput, MemrefInput
word 2 Pointer to ::_sss_sscp_asymmetric
word 3 Pointer to digest
word 4 digestLen
word 5 Pointer to signature
word 6 signatureLen
## Tunnel @copydetails sss_tunnel
Tunnel TX MU TXn register value
Command 0 kSSCP_CMD_SSS_Tunnel
paramTypes 1 Context, MemrefInput, Context, ValueInput
word 2 Pointer to ::_sss_sscp_tunnel
word 3 Pointer to input data buffer
word 4 Length of the input data buffer in bytes
word 5 Pointer to an array of ::_sss_sscp_object
word 6 Number of the elements in the array of ::_sss_sscp_object
word 7 Tunnel type id
## Derive key ### Asymmetric shared secret - Diffie-Helmann @copydetails sss_derive_key_dh
Asymmetric Derive Key TX MU TXn register value
Command 0 kSSCP_CMD_SSS_AsymmetricDeriveKey
paramTypes 1 Context, Context, Context
word 2 Pointer to ::_sss_sscp_derive_key
word 3 Pointer to ::_sss_sscp_object
word 4 Pointer to ::_sss_sscp_object
## Key Object ### Key Object Allocate Handle @copydetails sss_key_object_allocate_handle
Key Object Allocate Handle TX MU TXn register value
Command 0 kSSCP_CMD_SSS_KeyObjectAllocateHandle
paramTypes 1 Context, ValueInput, ValueInput
word 2 Pointer to ::_sss_sscp_object
word 3 keyId
word 4 keyType
word 5 keyByteLenMax
word 6 options
## Key Store ### Key Store Allocate @copydetails sss_key_store_allocate
Key Store Allocate TX MU TXn register value
Command 0 kSSCP_CMD_SSS_KeyStoreAllocate
paramTypes 1 Context, ValueInput
word 2 Pointer to ::_sss_sscp_key_store
word 3 keyStoreId
word 4 Zero
### Set key into key store @copydetails sss_key_store_set_key
Key Store Set Key TX MU TXn register value
Command 0 kSSCP_CMD_SSS_KeyStoreSetKey
paramTypes 1 Context, Context, MemrefInput, ValueInput, MemrefInput
word 2 Pointer to ::_sss_sscp_key_store
word 3 Pointer to ::_sss_sscp_object
word 4 Pointer to key buffer
word 5 Length of key buffer in bytes
word 6 Key Length in bits
word 7 Zero
word 8 Pointer to options buffer
word 9 Length of the options buffer in bytes
*/ /******************************************************************************* * API ******************************************************************************/ #if defined(__cplusplus) extern "C" { #endif /*! * @addtogroup sscp_mu * @{ */ /** * struct _sscp_mu_context - SSCP context struct for MU implementation * * This data type is used to keep context of the SSCP link. * It is completely implementation specific. * * @param context Container for the implementation specific data. */ typedef struct _sscp_mu_context { fn_sscp_invoke_command_t invoke; /*! Implementation specific part */ MU_Type *base; } sscp_mu_context_t; /*! @brief Initializes the SSCP link * * This function initializes the SSCP for operation - e.g.underlaying hardware is initialized * and prepared for data exchange. * * @param context Context structure for the SSCP. * @param base The MU peripheral base address to be used for communication * * @returns Status of the operation * @retval kStatus_SSCP_Success SSCP init success * @retval kStatus_SSCP_Fail SSCP init failure */ sscp_status_t sscp_mu_init(sscp_context_t *context, MU_Type *base); /*! @brief Close the SSCP link * * This function closes the SSCP link - e.g.underlying hardware is disabled. * * @param context Context structure for the SSCP. */ void sscp_mu_deinit(sscp_context_t *context); /*! @brief Sends a command and associated parameters to security sub-system * * The commandID and operation content is serialized and sent over to the selected security sub-system. * This is implementation specific function. * The function can invoke both blocking and non-blocking secure functions in the selected security sub-system. * * @param context Initialized SSCP context * @param commandID Command - an id of a remote secure function to be invoked * @param op Description of function arguments as a sequence of buffers and values * @param ret Return code of the remote secure function (application layer return value) * * @returns Status of the operation * @retval kStatus_SSCP_Success A blocking command has completed or a non-blocking command has been accepted. * @retval kStatus_SSCP_Fail Operation failure, for example hardware fail. * @retval kStatus_SSCP_InvalidArgument One of the arguments is invalid for the function to execute. */ sscp_status_t sscp_mu_invoke_command(sscp_context_t *context, uint32_t commandID, sscp_operation_t *op, uint32_t *ret); #if defined(__cplusplus) } #endif /*! *@} */ /* end of sscp_mu */ #endif /* _FSL_SSCP_MU_H_ */