ta/wallet_ta.c
/** Generate some (deterministic) random bytes from a HMAC_DRBG state. This
  * function is only used by the TA itself.
  * \param session_data A data pointer to a session context.
  * \param out Byte array which will receive the random bytes. This must be
  *            large enough to store requested_bytes bytes.
  * \param state The HMAC_DRBG state to get bytes from. The state must
  *              have been previously instantiated using drbgInstantiate().
  * \param requested_bytes Number of bytes to generate.
  * \param additional_input Optional additional data to mix into HMAC_DRBG
  *                         state. This may be NULL to indicate that there is
  *                         no additional input.
  * \param additional_input_length Length of additional input, in number of
  *                                bytes.
  */
Generate some (deterministic) random bytes from a HMAC_DRBG state. This
function is only used by the TA itself.
\param session_data A data pointer to a session context.
\param out Byte array which will receive the random bytes. This must be
large enough to store requested_bytes bytes.
\param state The HMAC_DRBG state to get bytes from. The state must
have been previously instantiated using drbgInstantiate().
\param requested_bytes Number of bytes to generate.
\param additional_input Optional additional data to mix into HMAC_DRBG
state. This may be NULL to indicate that there is
no additional input.
\param additional_input_length Length of additional input, in number of
bytes.
Generate some ( deterministic ) random bytes from a HMAC_DRBG state . This function is only used by the TA itself . \ param session_data A data pointer to a session context . \ param out Byte array which will receive the random bytes . This must be large enough to store requested_bytes bytes . \ param state The HMAC_DRBG state to get bytes from . The state must have been previously instantiated using drbgInstantiate () . \ param requested_bytes Number of bytes to generate . \ param additional_input Optional additional data to mix into HMAC_DRBG state . This may be NULL to indicate that there is no additional input . \ param additional_input_length Length of additional input in number of bytes .
static void drbg_generate_internal(Session_data * session_data, uint8_t *out, HMACDRBGState *state, const unsigned int requested_bytes, const uint8_t *additional_input, const unsigned int additional_input_length)
{
	unsigned int bytes;
	unsigned int copy_size;
	if (additional_input != NULL)
		drbg_update_internal(session_data,
							state,
							additional_input,
							additional_input_length);
	bytes = 0;
	while (bytes < requested_bytes)
	{
		hmac_sha256_internal(session_data,
							state->v,
							state->v,
							sizeof(state->v),
							NULL,
							0);
		copy_size = MIN(requested_bytes - bytes, sizeof(state->v));
		TEE_MemMove((uint8_t*)&(out[bytes]),
					(uint8_t*)(state->v),
					(uint32_t)copy_size);
		bytes += copy_size;
	}
	drbg_update_internal(session_data,
						state,
						additional_input,
						additional_input_length);
}
static void drbg_generate_internal ( Session_data * session_data , uint8_t * out , HMACDRBGState * state , const unsigned int requested_bytes , const uint8_t * additional_input , const unsigned int additional_input_length ) { unsigned int bytes ; unsigned int copy_size ; if ( additional_input != NULL ) drbg_update_internal ( session_data , state , additional_input , additional_input_length ) ; bytes = 0 ; while ( bytes < requested_bytes ) { hmac_sha256_internal ( session_data , state -> v , state -> v , sizeof ( state -> v ) , NULL , 0 ) ; copy_size = MIN ( requested_bytes - bytes , sizeof ( state -> v ) ) ; TEE_MemMove ( ( uint8_t * ) & ( out [ bytes ] ) , ( uint8_t * ) ( state -> v ) , ( uint32_t ) copy_size ) ; bytes += copy_size ; } drbg_update_internal ( session_data , state , additional_input , additional_input_length ) ; }
Generate some (deterministic) random bytes from a HMAC_DRBG state.
Generate some ( deterministic ) random bytes from a HMAC_DRBG state .
/* V = HMAC (Key, V). */