ta/wallet_ta.c
/**
  * Called to initialize the operation handles allocated in the session context.
  * \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.
  */
Called to initialize the operation handles allocated in the session context.
\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.
Called to initialize the operation handles allocated in the session context . \ 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 initialize_handlers(Session_data * session_data, uint32_t param_types, TEE_Param params[4])
{
	TEE_Result result = TEE_SUCCESS;
	uint32_t exp_param_types = TEE_PARAM_TYPES(
									TEE_PARAM_TYPE_NONE,
									TEE_PARAM_TYPE_NONE,
									TEE_PARAM_TYPE_NONE,
									TEE_PARAM_TYPE_NONE);
	(void)&params;
	if (param_types != exp_param_types)
		return TEE_ERROR_BAD_PARAMETERS;
    result = TEE_AllocateOperation(session_data->aes_encrypt_op,
    								TEE_ALG_AES_XTS,
    								TEE_MODE_ENCRYPT,
    								(uint32_t)(2*128));
    if (result != TEE_SUCCESS)
    {
    	#ifdef OP_TEE_TA
    	DMSG("Failed to allocate the handler for AES-XTS encryption operation: 0x%x", result);
    	#endif
    	goto cleanup1;
    }
    result = TEE_AllocateOperation(session_data->aes_decrypt_op,
    								TEE_ALG_AES_XTS,
    								TEE_MODE_DECRYPT,
    								(uint32_t)(2*128));
    if (result != TEE_SUCCESS)
    {
    	#ifdef OP_TEE_TA
    	DMSG("Failed to allocate the handler for AES-XTS decryption operation: 0x%x", result);
    	#endif
    	goto cleanup1;
    }
    result = set_encryption_key_internal(session_data, dummy_key);
    if (result != TEE_SUCCESS)
    {
    	#ifdef OP_TEE_TA
    	DMSG("Failed to set the keys for AES-XTS: 0x%x", result);
    	#endif
    	goto cleanup1;
    }
    result = TEE_AllocateOperation(session_data->hmac_op1_internal,
    								TEE_ALG_HMAC_SHA512,
    								TEE_MODE_MAC,
    								(uint32_t)MAX_HMAC_SHA_512_KEY_SIZE);
    if (result != TEE_SUCCESS)
    {
    	#ifdef OP_TEE_TA
    	DMSG("Failed to allocate the handler for HMAC-SHA512 internal operation: 0x%x", result);
    	#endif
    	goto cleanup1;
    }
    result = TEE_AllocateOperation(session_data->hmac_op2_internal,
    								TEE_ALG_HMAC_SHA256,
    								TEE_MODE_MAC,
    								(uint32_t)MAX_HMAC_SHA_256_KEY_SIZE);
    if (result != TEE_SUCCESS)
    {
    	#ifdef OP_TEE_TA
    	DMSG("Failed to allocate the handler for HMAC-SHA256 internal operation: 0x%x", result);
    	#endif
    	goto cleanup1;
    }
    result = TEE_AllocateOperation(session_data->hmac_op1,
    								TEE_ALG_HMAC_SHA512,
    								TEE_MODE_MAC,
    								(uint32_t)MAX_HMAC_SHA_512_KEY_SIZE);
    if (result != TEE_SUCCESS)
    {
    	#ifdef OP_TEE_TA
    	DMSG("Failed to allocate the handler for HMAC-SHA512 operation: 0x%x", result);
    	#endif
    	goto cleanup1;
    }
    result = TEE_AllocateOperation(session_data->hmac_op2,
    								TEE_ALG_HMAC_SHA256,
    								TEE_MODE_MAC,
    								(uint32_t)MAX_HMAC_SHA_256_KEY_SIZE);
    if (result != TEE_SUCCESS)
    {
    	#ifdef OP_TEE_TA
    	DMSG("Failed to allocate the handler for HMAC-SHA256 operation: 0x%x", result);
    	#endif
    	goto cleanup1;
    }
    result = TEE_AllocateOperation(session_data->sha_op_internal,
    								TEE_ALG_SHA256,
    								TEE_MODE_DIGEST,
    								(uint32_t)0);
    if (result != TEE_SUCCESS)
    {
    	#ifdef OP_TEE_TA
    	DMSG("Failed to allocate the handler for SHA-256 internal operation: 0x%x", result);
    	#endif
    	goto cleanup1;
    }
    result = TEE_AllocateOperation(session_data->sha_op1,
    								TEE_ALG_SHA256,
    								TEE_MODE_DIGEST,
    								(uint32_t)0);
    if (result != TEE_SUCCESS)
    {
    	#ifdef OP_TEE_TA
    	DMSG("Failed to allocate the handler for SHA-256 operation: 0x%x", result);
    	#endif
    	goto cleanup1;
    }
    result = TEE_AllocateOperation(session_data->sha_op2,
    								TEE_ALG_SHA256,
    								TEE_MODE_DIGEST,
    								(uint32_t)0);
    if (result != TEE_SUCCESS)
    {
    	#ifdef OP_TEE_TA
    	DMSG("Failed to allocate the handler 2 for SHA-256 operation: 0x%x", result);
    	#endif
    	goto cleanup1;
    }
    result = TEE_AllocateOperation(session_data->sha_op3,
    								TEE_ALG_SHA256,
    								TEE_MODE_DIGEST,
    								(uint32_t)0);
    if (result != TEE_SUCCESS)
    {
    	#ifdef OP_TEE_TA
    	DMSG("Failed to allocate the handler 3 for SHA-256 operation: 0x%x", result);
    	#endif
    	goto cleanup1;
    }
    result = TEE_AllocateOperation(session_data->sha_op4,
    								TEE_ALG_SHA256,
    								TEE_MODE_DIGEST,
    								(uint32_t)0);
    if (result != TEE_SUCCESS)
    {
    	#ifdef OP_TEE_TA
    	DMSG("Failed to allocate the handler 4 for SHA-256 operation: 0x%x", result);
    	#endif
    	goto cleanup1;
    }
    cleanup1:
   		return result;
}
static TEE_Result initialize_handlers ( Session_data * session_data , uint32_t param_types , TEE_Param params [ 4 ] ) { TEE_Result result = TEE_SUCCESS ; uint32_t exp_param_types = TEE_PARAM_TYPES ( TEE_PARAM_TYPE_NONE , TEE_PARAM_TYPE_NONE , TEE_PARAM_TYPE_NONE , TEE_PARAM_TYPE_NONE ) ; ( void ) & params ; if ( param_types != exp_param_types ) return TEE_ERROR_BAD_PARAMETERS ; result = TEE_AllocateOperation ( session_data -> aes_encrypt_op , TEE_ALG_AES_XTS , TEE_MODE_ENCRYPT , ( uint32_t ) ( 2 * 128 ) ) ; if ( result != TEE_SUCCESS ) { #ifdef OP_TEE_TA DMSG ( " " , result ) ; #endif goto cleanup1 ; } result = TEE_AllocateOperation ( session_data -> aes_decrypt_op , TEE_ALG_AES_XTS , TEE_MODE_DECRYPT , ( uint32_t ) ( 2 * 128 ) ) ; if ( result != TEE_SUCCESS ) { #ifdef OP_TEE_TA DMSG ( " " , result ) ; #endif goto cleanup1 ; } result = set_encryption_key_internal ( session_data , dummy_key ) ; if ( result != TEE_SUCCESS ) { #ifdef OP_TEE_TA DMSG ( " " , result ) ; #endif goto cleanup1 ; } result = TEE_AllocateOperation ( session_data -> hmac_op1_internal , TEE_ALG_HMAC_SHA512 , TEE_MODE_MAC , ( uint32_t ) MAX_HMAC_SHA_512_KEY_SIZE ) ; if ( result != TEE_SUCCESS ) { #ifdef OP_TEE_TA DMSG ( " " , result ) ; #endif goto cleanup1 ; } result = TEE_AllocateOperation ( session_data -> hmac_op2_internal , TEE_ALG_HMAC_SHA256 , TEE_MODE_MAC , ( uint32_t ) MAX_HMAC_SHA_256_KEY_SIZE ) ; if ( result != TEE_SUCCESS ) { #ifdef OP_TEE_TA DMSG ( " " , result ) ; #endif goto cleanup1 ; } result = TEE_AllocateOperation ( session_data -> hmac_op1 , TEE_ALG_HMAC_SHA512 , TEE_MODE_MAC , ( uint32_t ) MAX_HMAC_SHA_512_KEY_SIZE ) ; if ( result != TEE_SUCCESS ) { #ifdef OP_TEE_TA DMSG ( " " , result ) ; #endif goto cleanup1 ; } result = TEE_AllocateOperation ( session_data -> hmac_op2 , TEE_ALG_HMAC_SHA256 , TEE_MODE_MAC , ( uint32_t ) MAX_HMAC_SHA_256_KEY_SIZE ) ; if ( result != TEE_SUCCESS ) { #ifdef OP_TEE_TA DMSG ( " " , result ) ; #endif goto cleanup1 ; } result = TEE_AllocateOperation ( session_data -> sha_op_internal , TEE_ALG_SHA256 , TEE_MODE_DIGEST , ( uint32_t ) 0 ) ; if ( result != TEE_SUCCESS ) { #ifdef OP_TEE_TA DMSG ( " " , result ) ; #endif goto cleanup1 ; } result = TEE_AllocateOperation ( session_data -> sha_op1 , TEE_ALG_SHA256 , TEE_MODE_DIGEST , ( uint32_t ) 0 ) ; if ( result != TEE_SUCCESS ) { #ifdef OP_TEE_TA DMSG ( " " , result ) ; #endif goto cleanup1 ; } result = TEE_AllocateOperation ( session_data -> sha_op2 , TEE_ALG_SHA256 , TEE_MODE_DIGEST , ( uint32_t ) 0 ) ; if ( result != TEE_SUCCESS ) { #ifdef OP_TEE_TA DMSG ( " " , result ) ; #endif goto cleanup1 ; } result = TEE_AllocateOperation ( session_data -> sha_op3 , TEE_ALG_SHA256 , TEE_MODE_DIGEST , ( uint32_t ) 0 ) ; if ( result != TEE_SUCCESS ) { #ifdef OP_TEE_TA DMSG ( " " , result ) ; #endif goto cleanup1 ; } result = TEE_AllocateOperation ( session_data -> sha_op4 , TEE_ALG_SHA256 , TEE_MODE_DIGEST , ( uint32_t ) 0 ) ; if ( result != TEE_SUCCESS ) { #ifdef OP_TEE_TA DMSG ( " " , result ) ; #endif goto cleanup1 ; } cleanup1 : return result ; }
Called to initialize the operation handles allocated in the session context.
Called to initialize the operation handles allocated in the session context .
/* It is not expected any parameters */ /* Unused parameters */ /* Check the type of the parameters received */ /*
	 * Allocate the AES XTS encryption operation with the correspondent
	 * handler. The key is a combination of two keys each one with 128 bits
	 * so the final will have the key size of 2*128
	 */ /*
     * Allocate the AES XTS decryption operation with the correspondent
     * handler. The key is a combination of two keys each one with 128 bits
	 * so the final will have the key size of 2*128
	 */ /* Seth the 'dummy' key as encryption key */ /* Allocate the HMAC-SHA-512 operation with the correspondent handler */ /* Allocate the HMAC-SHA-256 operation with the correspondent handler */ /* Allocate the HMAC-SHA-512 operation with the correspondent handler */ /* Allocate the HMAC-SHA-256 operation with the correspondent handler */ /* Allocate the SHA-256 operation with the correspondent handler */ /* Allocate the SHA-256 operation with the correspondent handler */ /* Allocate the second SHA-256 operation with the correspondent handler */ /* Allocate the third SHA-256 operation with the correspondent handler */ /* Allocate the forth SHA-256 operation with the correspondent handler */ /* Resources cleanup */