ta/wallet_ta.c
/**
  * Executes the HMAC-SHA-512 operation.
  * \param session_data A data pointer to a session context.
  * \param param_types The types of the four parameters.
  * \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-512 operation.
\param session_data A data pointer to a session context.
\param param_types The types of the four parameters.
\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 - 512 operation . \ param session_data A data pointer to a session context . \ param param_types The types of the four parameters . \ 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_sha512(Session_data * session_data, uint32_t param_types, TEE_Param params[4])
{
	TEE_Result result = TEE_SUCCESS;
	uint32_t exp_param_types;
	uint32_t hash_length;
	exp_param_types = TEE_PARAM_TYPES(
							TEE_PARAM_TYPE_MEMREF_OUTPUT,
							TEE_PARAM_TYPE_MEMREF_INPUT,
							TEE_PARAM_TYPE_NONE,
							TEE_PARAM_TYPE_NONE);
	if (param_types != exp_param_types
		|| params[0].memref.buffer == NULL
		|| params[1].memref.buffer == NULL)
		return TEE_ERROR_BAD_PARAMETERS;
    TEE_MACInit(*(session_data->hmac_op1), NULL, 0);
    hash_length = (uint32_t)(params[0].memref.size);
    result = TEE_MACComputeFinal(
    				*(session_data->hmac_op1),
    				(uint8_t*)(params[1].memref.buffer),
    				(uint32_t)(params[1].memref.size),
    				(uint8_t*)(params[0].memref.buffer),
    				&hash_length);
    if (result != TEE_SUCCESS)
    {
    	#ifdef OP_TEE_TA
    	DMSG("Failed to finalize HMAC-SHA-512 operation: 0x%x", result);
    	#endif
    }
	return result;
}
static TEE_Result hmac_sha512 ( Session_data * session_data , uint32_t param_types , TEE_Param params [ 4 ] ) { TEE_Result result = TEE_SUCCESS ; uint32_t exp_param_types ; uint32_t hash_length ; exp_param_types = TEE_PARAM_TYPES ( TEE_PARAM_TYPE_MEMREF_OUTPUT , TEE_PARAM_TYPE_MEMREF_INPUT , TEE_PARAM_TYPE_NONE , TEE_PARAM_TYPE_NONE ) ; if ( param_types != exp_param_types || params [ 0 ] . memref . buffer == NULL || params [ 1 ] . memref . buffer == NULL ) return TEE_ERROR_BAD_PARAMETERS ; TEE_MACInit ( * ( session_data -> hmac_op1 ) , NULL , 0 ) ; hash_length = ( uint32_t ) ( params [ 0 ] . memref . size ) ; result = TEE_MACComputeFinal ( * ( session_data -> hmac_op1 ) , ( uint8_t * ) ( params [ 1 ] . memref . buffer ) , ( uint32_t ) ( params [ 1 ] . memref . size ) , ( uint8_t * ) ( params [ 0 ] . memref . buffer ) , & hash_length ) ; if ( result != TEE_SUCCESS ) { #ifdef OP_TEE_TA DMSG ( " " , result ) ; #endif } return result ; }
Executes the HMAC-SHA-512 operation.
Executes the HMAC - SHA - 512 operation .
/*
	 * Expected:
	 * [OUT] params[0].memref.buffer -> Buffer to write the resulted hash.
	 * [OUT] params[0].memref.size   -> Size of of the buffer.
	 * [IN]  params[1].memref.buffer -> Input buffer with the text to be hashed.
	 * [IN]  params[1].memref.size   -> Size of the input buffer.
	 */ /* Some sanity checks */ /* Initialize MAC operation */ /*
     * Here we could call TEE_MACUpdate but as we will use just one input
     * message it is not needed instead we could use TEE_MACComputeFinal to
     * finalize and accumulate the data.
     */ /* Define the hash size */ /*
     * Finalize the MAC operation with a last chunk of message, and computes
     * the MAC
     */