ta/wallet_ta.c
/** Change the name of the currently loaded wallet.
  * \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.
  */
Change the name of the currently loaded wallet.
\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.
Change the name of the currently loaded wallet . \ 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 change_wallet_name(Session_data * session_data, uint32_t param_types, TEE_Param params[4])
{
	TEE_Result result = TEE_SUCCESS;
	uint32_t exp_param_types;
	WalletErrors wallet_error = WALLET_NO_ERROR;
	TEE_Param wcwr_params[4];
	uint32_t wcwr_param_types;
	exp_param_types = TEE_PARAM_TYPES(
							TEE_PARAM_TYPE_MEMREF_INPUT,
							TEE_PARAM_TYPE_VALUE_OUTPUT,
							TEE_PARAM_TYPE_NONE,
							TEE_PARAM_TYPE_NONE);
	wcwr_param_types = TEE_PARAM_TYPES(
							TEE_PARAM_TYPE_VALUE_INPUT,
							TEE_PARAM_TYPE_NONE,
							TEE_PARAM_TYPE_NONE,
							TEE_PARAM_TYPE_NONE);
	if (param_types != exp_param_types || params[0].memref.buffer == NULL)
		return TEE_ERROR_BAD_PARAMETERS;
	if (!(session_data->wallet_loaded))
	{
		result = TEE_ERROR_BAD_STATE;
		wallet_error = WALLET_NOT_LOADED;
	}
	if (session_data->is_hidden_wallet)
	{
		result = TEE_ERROR_BAD_STATE;
		wallet_error = WALLET_INVALID_OPERATION;
	}
	TEE_MemMove(
		(uint8_t*)&(session_data->current_wallet->unencrypted.name),
		(uint8_t*)(params[0].memref.buffer),
		(uint32_t)(params[0].memref.size));
	calculate_wallet_checksum_internal(
		session_data,
		session_data->current_wallet->encrypted.checksum);
	wcwr_params[0].value.a = session_data->wallet_nv_address;
	result = write_current_wallet_record(session_data,
										wcwr_param_types,
										wcwr_params);
	if(result != TEE_SUCCESS)
	{
		#ifdef OP_TEE_TA
		DMSG("Failed to do write_current_wallet_record operation : 0x%x", result);
		#endif
		wallet_error = WALLET_WRITE_ERROR;
		goto cleanup1;
	}
	cleanup1:
		params[1].value.a = (uint32_t)wallet_error;
		return result;
}
static TEE_Result change_wallet_name ( Session_data * session_data , uint32_t param_types , TEE_Param params [ 4 ] ) { TEE_Result result = TEE_SUCCESS ; uint32_t exp_param_types ; WalletErrors wallet_error = WALLET_NO_ERROR ; TEE_Param wcwr_params [ 4 ] ; uint32_t wcwr_param_types ; exp_param_types = TEE_PARAM_TYPES ( TEE_PARAM_TYPE_MEMREF_INPUT , TEE_PARAM_TYPE_VALUE_OUTPUT , TEE_PARAM_TYPE_NONE , TEE_PARAM_TYPE_NONE ) ; wcwr_param_types = TEE_PARAM_TYPES ( TEE_PARAM_TYPE_VALUE_INPUT , TEE_PARAM_TYPE_NONE , TEE_PARAM_TYPE_NONE , TEE_PARAM_TYPE_NONE ) ; if ( param_types != exp_param_types || params [ 0 ] . memref . buffer == NULL ) return TEE_ERROR_BAD_PARAMETERS ; if ( ! ( session_data -> wallet_loaded ) ) { result = TEE_ERROR_BAD_STATE ; wallet_error = WALLET_NOT_LOADED ; } if ( session_data -> is_hidden_wallet ) { result = TEE_ERROR_BAD_STATE ; wallet_error = WALLET_INVALID_OPERATION ; } TEE_MemMove ( ( uint8_t * ) & ( session_data -> current_wallet -> unencrypted . name ) , ( uint8_t * ) ( params [ 0 ] . memref . buffer ) , ( uint32_t ) ( params [ 0 ] . memref . size ) ) ; calculate_wallet_checksum_internal ( session_data , session_data -> current_wallet -> encrypted . checksum ) ; wcwr_params [ 0 ] . value . a = session_data -> wallet_nv_address ; result = write_current_wallet_record ( session_data , wcwr_param_types , wcwr_params ) ; if ( result != TEE_SUCCESS ) { #ifdef OP_TEE_TA DMSG ( " " , result ) ; #endif wallet_error = WALLET_WRITE_ERROR ; goto cleanup1 ; } cleanup1 : params [ 1 ] . value . a = ( uint32_t ) wallet_error ; return result ; }
Change the name of the currently loaded wallet.
Change the name of the currently loaded wallet .
/* Declare writeCurrentWallet operation parameters */ /*
	 * Expected:
	 * [IN]  params[0].memref.buffer -> New name
	 * [IN]  params[0].memref.size   -> Size of New name.
	 * [OUT] params[1].value.a       -> WalletError;
	 */ /*
	 * writeCurrentWallet parameters:
	 * [IN]  params[0].value.a    -> Address to write the current wallet record.
	 */ /* Some sanity check on the parameters received */ /*
         * Wallet name updates on a hidden wallet would reveal where it is
         * (since names are publicly visible), so don't allow name changes.
         */ /* Write the current wallet record into the storage */ /* Resources cleanup */