[SLOF] [PATCH 12/16] Add TPM firmware API calls hash-all, log-event, hash-log-extend-event

Stefan Berger stefanb at linux.vnet.ibm.com
Fri Nov 13 03:00:47 AEDT 2015


On 11/12/2015 01:08 AM, Nikunj A Dadhania wrote:
> Stefan Berger <stefanb at linux.vnet.ibm.com> writes:
>
>> diff --git a/lib/libtpm/tcgbios.c b/lib/libtpm/tcgbios.c
>> index adec313..621c3e8 100644
>> --- a/lib/libtpm/tcgbios.c
>> +++ b/lib/libtpm/tcgbios.c
>> @@ -563,6 +563,20 @@ static uint32_t tpm_extend_ofdt_log(struct pcpes *pcpes,
>>   	return 0;
>>   }
>>
>> +/*
>> + * tpm_log_event: Function for interfacing with the firmware API
>> + */
>> +bool tpm_log_event(struct pcpes *pcpes)
>> +{
>> +	const char *event = NULL;
>> +	uint32_t event_length = pcpes->eventdatasize;
>> +
>> +	if (event_length)
>> +		event = (void *)pcpes + offset_of(struct pcpes, event);
>> +
>> +	return (tpm_extend_ofdt_log(pcpes, event, event_length) == 0);
> Do you want to call this when event_length is 0 ?

The pcpes part is one part that is being logged and the event part is 
appended to it. The pcpes part alone can be sufficient for appending to 
the log.


>
>> +}
>> +
>>   static uint32_t is_preboot_if_shutdown(void)
>>   {
>>   	return tpm_state.if_shutdown;
>> @@ -656,6 +670,14 @@ static uint32_t tpm_extend(uint8_t *hash, uint32_t pcrindex)
>>   }
>>
>>   /*
>> + * tpm_hash_all: Function for interfacing with the firmware API
>> + */
>> +uint32_t tpm_hash_all(const void *data, uint32_t datalen, void *hashptr)
>> +{
>> +	return sha1(data, datalen, hashptr);
>> +}
>> +
>> +/*
>>    * Hash then given input data and append the hash to the log
>>    *
>>    * @hashdata: the data to hash
>> @@ -766,6 +788,25 @@ static uint32_t tpm_add_measurement(uint32_t pcrindex,
>>   }
>>
>>   /*
>> + * tpm_hash_log_extend_event: Function for interfacing with then firmware API
>> + */
>> +uint32_t tpm_hash_log_extend_event(struct pcpes *pcpes)
>> +{
>> +	const char *event = NULL;
>> +	uint32_t event_length = pcpes->eventdatasize;
>> +
>> +	if (!has_working_tpm())
>> +		return TCGBIOS_GENERAL_ERROR;
>> +
>> +	if (event_length)
>> +		event = (void *)pcpes + offset_of(struct pcpes, event);
>> +
>> +	return hash_log_extend_event(&pcpes->event, pcpes->eventdatasize,
>> +				     pcpes, event, event_length,
>> +				     pcpes->pcrindex);
> Ditto here, you have a NULL event, what would add to log?

event_length would be 0, so only 'pcpes' would be appended to the log.

   Stefan



More information about the SLOF mailing list