ta/wallet_ta.c
/**
  * Executes the HMAC-SHA-256 operation. This function is only used by the TA
  * itself.
  * \param session_data A data pointer to a session context.
  * \param out A byte array where the HMAC-SHA256 hash value will be written.
  *            This must have space for #SHA256_HASH_LENGTH bytes.
  * \param text1 A byte array containing the first part of the message to use
  *              in the HMAC-SHA256 calculation. The message can be of any
  *              length.
  * \param text1_length The length, in bytes, of the first part of the message.
  * \param text2 A byte array containing the second part of the message to use
  *              in the HMAC-SHA256 calculation. This part will be appended to
  *              the first part of the message. This parameter is optional; it
  *              can be NULL.
  * \param text2_length The length, in bytes, of the second part of the message.
  * \param params A pointer to an array of four parameters.
  * \return TEE_SUCCESS in case of success otherwise returns the result
  *         received from the failed operation. The information about all
  *         possible returns is present in TEE Client API Specification - 4.4.2
  *         published by GlobalPlatform.
  */
Executes the HMAC-SHA-256 operation. This function is only used by the TA
itself.
\param session_data A data pointer to a session context.
\param out A byte array where the HMAC-SHA256 hash value will be written.
This must have space for #SHA256_HASH_LENGTH bytes.
\param text1 A byte array containing the first part of the message to use
in the HMAC-SHA256 calculation. The message can be of any
length.
\param text1_length The length, in bytes, of the first part of the message.
\param text2 A byte array containing the second part of the message to use
in the HMAC-SHA256 calculation. This part will be appended to
the first part of the message. This parameter is optional; it
can be NULL.
\param text2_length The length, in bytes, of the second part of the message.
\param params A pointer to an array of four parameters.
\return TEE_SUCCESS in case of success otherwise returns the result
received from the failed operation. The information about all
possible returns is present in TEE Client API Specification - 4.4.2
published by GlobalPlatform.
Executes the HMAC - SHA - 256 operation . This function is only used by the TA itself . \ param session_data A data pointer to a session context . \ param out A byte array where the HMAC - SHA256 hash value will be written . This must have space for #SHA256_HASH_LENGTH bytes . \ param text1 A byte array containing the first part of the message to use in the HMAC - SHA256 calculation . The message can be of any length . \ param text1_length The length in bytes of the first part of the message . \ param text2 A byte array containing the second part of the message to use in the HMAC - SHA256 calculation . This part will be appended to the first part of the message . This parameter is optional ; it can be NULL . \ param text2_length The length in bytes of the second part of the message . \ param params A pointer to an array of four parameters . \ return TEE_SUCCESS in case of success otherwise returns the result received from the failed operation . The information about all possible returns is present in TEE Client API Specification - 4 . 4 . 2 published by GlobalPlatform .
static TEE_Result hmac_sha256_internal(Session_data * session_data, uint8_t *out, const uint8_t *text1, const unsigned int text1_length, const uint8_t *text2, const unsigned int text2_length)
{
	TEE_Result result = TEE_SUCCESS;
	uint32_t hash_length;
    TEE_MACInit(*(session_data->hmac_op2_internal), NULL, 0);
    TEE_MACUpdate(*(session_data->hmac_op2_internal), (uint8_t*)text1, (uint32_t)text1_length);
    hash_length = SHA256_HASH_LENGTH;
    result = TEE_MACComputeFinal(*(session_data->hmac_op2_internal),
    							(uint8_t*)text2,
    							(uint32_t)text2_length,
    							(uint8_t*)out,
    							&hash_length);
    if (result != TEE_SUCCESS)
	{
		#ifdef OP_TEE_TA
		DMSG("Failed to finalize HMAC-SHA-256 operation: 0x%x", result);
		#endif
	}
	return result;
}
static TEE_Result hmac_sha256_internal ( Session_data * session_data , uint8_t * out , const uint8_t * text1 , const unsigned int text1_length , const uint8_t * text2 , const unsigned int text2_length ) { TEE_Result result = TEE_SUCCESS ; uint32_t hash_length ; TEE_MACInit ( * ( session_data -> hmac_op2_internal ) , NULL , 0 ) ; TEE_MACUpdate ( * ( session_data -> hmac_op2_internal ) , ( uint8_t * ) text1 , ( uint32_t ) text1_length ) ; hash_length = SHA256_HASH_LENGTH ; result = TEE_MACComputeFinal ( * ( session_data -> hmac_op2_internal ) , ( uint8_t * ) text2 , ( uint32_t ) text2_length , ( uint8_t * ) out , & hash_length ) ; if ( result != TEE_SUCCESS ) { #ifdef OP_TEE_TA DMSG ( " " , result ) ; #endif } return result ; }
Executes the HMAC-SHA-256 operation.
Executes the HMAC - SHA - 256 operation .
/* Initialize MAC operation */ /* Define the hash size */ /* Finalize the MAC operation with a last chunk of message, and computes the MAC */