ta/wallet_ta.c
/** Wrapper of ecdsa_sign_internal() for a CA command.
  * \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.
  */
Wrapper of ecdsa_sign_internal() for a CA command.
\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.
Wrapper of ecdsa_sign_internal () for a CA command . \ 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 ecdsa_sign(Session_data * session_data, uint32_t param_types, TEE_Param params[4])
{
	WalletErrors wallet_error = WALLET_NO_ERROR;
	TEE_Result result = TEE_SUCCESS;
	uint32_t exp_param_types;
	uint8_t private_key[32];
	exp_param_types = TEE_PARAM_TYPES(
							TEE_PARAM_TYPE_MEMREF_OUTPUT,
							TEE_PARAM_TYPE_MEMREF_OUTPUT,
							TEE_PARAM_TYPE_MEMREF_INPUT,
							TEE_PARAM_TYPE_VALUE_INOUT);
	if (param_types != exp_param_types
	 || params[0].memref.buffer == NULL
	 || params[1].memref.buffer == NULL
	 || params[2].memref.buffer == NULL)
		return TEE_ERROR_BAD_PARAMETERS;
	wallet_error = get_private_key_internal(session_data,
											private_key,
											(AddressHandle)(params[3].value.a));
	if (wallet_error != WALLET_NO_ERROR)
	{
		result = TEE_ERROR_BAD_STATE;
		goto cleanup1;
	}
	ecdsa_sign_internal(session_data, private_key, params);
	cleanup1:
		params[3].value.b = (uint32_t)wallet_error;
		return result;
}
static TEE_Result ecdsa_sign ( Session_data * session_data , uint32_t param_types , TEE_Param params [ 4 ] ) { WalletErrors wallet_error = WALLET_NO_ERROR ; TEE_Result result = TEE_SUCCESS ; uint32_t exp_param_types ; uint8_t private_key [ 32 ] ; exp_param_types = TEE_PARAM_TYPES ( TEE_PARAM_TYPE_MEMREF_OUTPUT , TEE_PARAM_TYPE_MEMREF_OUTPUT , TEE_PARAM_TYPE_MEMREF_INPUT , TEE_PARAM_TYPE_VALUE_INOUT ) ; if ( param_types != exp_param_types || params [ 0 ] . memref . buffer == NULL || params [ 1 ] . memref . buffer == NULL || params [ 2 ] . memref . buffer == NULL ) return TEE_ERROR_BAD_PARAMETERS ; wallet_error = get_private_key_internal ( session_data , private_key , ( AddressHandle ) ( params [ 3 ] . value . a ) ) ; if ( wallet_error != WALLET_NO_ERROR ) { result = TEE_ERROR_BAD_STATE ; goto cleanup1 ; } ecdsa_sign_internal ( session_data , private_key , params ) ; cleanup1 : params [ 3 ] . value . b = ( uint32_t ) wallet_error ; return result ; }
Wrapper of ecdsa_sign_internal() for a CA command.
Wrapper of ecdsa_sign_internal () for a CA command .
/*
	 * Expected:
	 * [OUT] params[0].memref.buffer -> The "r" component of the signature.
	 * [OUT] params[0].memref.size   -> Size of "r".
	 * [OUT] params[1].memref.buffer -> The "s" component of the signature.
	 * [OUT] params[1].memref.size   -> Size of "s".
	 * [IN]  params[2].memref.buffer -> The message digest of the message to sign.
	 * [IN]  params[2].memref.size   -> Size of message.
	 * [IN]  params[3].value.a   	 -> AddressHandle of the private key.
	 * [OUT] params[3].value.b   	 -> WalletErrors return of get private key.
	 */ /* Some sanity checks */ /* Get the private key */ /* Resources cleanup */