// Measure implements the attestation reports generic Measure interface to be called
// as a plugin during attestation report generation
Measure implements the attestation reports generic Measure interface to be called
as a plugin during attestation report generation
// Measure implements the attestation reports generic Measure interface to be called // as a plugin during attestation report generation
func (t *Tpm) Measure(mp ar.MeasurementParams) (ar.Measurement, error) {
	tpmParams, ok := mp.(ar.TpmParams)
	if !ok {
		return ar.TpmMeasurement{}, fmt.Errorf("Failed to get TPM params - invalid type")
	}
	pcrValues, quote, err := GetTpmMeasurement(t, tpmParams.Nonce, tpmParams.Pcrs)
	if err != nil {
		return ar.TpmMeasurement{}, fmt.Errorf("Failed to get TPM Measurement: %v", err)
	}
	hashChain := make([]*ar.HashChainElem, len(tpmParams.Pcrs))
	for i, num := range tpmParams.Pcrs {
		hashChain[i] = &ar.HashChainElem{
			Type:   "Hash Chain",
			Pcr:    int32(num),
			Sha256: []string{hex.EncodeToString(pcrValues[num].Digest)}}
	}
	if tpmParams.UseIma {
		imaDigests, err := ima.GetImaRuntimeDigests()
		if err != nil {
			log.Error("Failed to get IMA runtime digests. Ignoring..")
		}
		imaDigestsHex := make([]string, 0)
		for _, elem := range imaDigests {
			imaDigestsHex = append(imaDigestsHex, hex.EncodeToString(elem[:]))
		}
		for _, elem := range hashChain {
			if elem.Pcr == tpmParams.ImaPcr {
				elem.Sha256 = imaDigestsHex
			}
		}
	}
	tm := ar.TpmMeasurement{
		Type:      "TPM Measurement",
		HashChain: hashChain,
		Message:   hex.EncodeToString(quote.Quote),
		Signature: hex.EncodeToString(quote.Signature),
		Certs:     tpmParams.Certs,
	}
	for i, elem := range tm.HashChain {
		log.Debug(fmt.Sprintf("[%v], PCR%v: %v\n", i, elem.Pcr, elem.Sha256))
	}
	log.Debug("Quote: ", tm.Message)
	log.Debug("Signature: ", tm.Signature)
	return tm, nil
}
func ( t * Tpm ) Measure ( mp ar . MeasurementParams ) ( ar . Measurement , error ) { tpmParams , ok := mp . ( ar . TpmParams ) if ! ok { return ar . TpmMeasurement { } , fmt . Errorf ( " " ) } pcrValues , quote , err := GetTpmMeasurement ( t , tpmParams . Nonce , tpmParams . Pcrs ) if err != nil { return ar . TpmMeasurement { } , fmt . Errorf ( " " , err ) } hashChain := make ( [ ] * ar . HashChainElem , len ( tpmParams . Pcrs ) ) for i , num := range tpmParams . Pcrs { hashChain [ i ] = & ar . HashChainElem { Type : " " , Pcr : int32 ( num ) , Sha256 : [ ] string { hex . EncodeToString ( pcrValues [ num ] . Digest ) } } } if tpmParams . UseIma { imaDigests , err := ima . GetImaRuntimeDigests ( ) if err != nil { log . Error ( " " ) } imaDigestsHex := make ( [ ] string , 0 ) for _ , elem := range imaDigests { imaDigestsHex = append ( imaDigestsHex , hex . EncodeToString ( elem [ : ] ) ) } for _ , elem := range hashChain { if elem . Pcr == tpmParams . ImaPcr { elem . Sha256 = imaDigestsHex } } } tm := ar . TpmMeasurement { Type : " " , HashChain : hashChain , Message : hex . EncodeToString ( quote . Quote ) , Signature : hex . EncodeToString ( quote . Signature ) , Certs : tpmParams . Certs , } for i , elem := range tm . HashChain { log . Debug ( fmt . Sprintf ( " \n " , i , elem . Pcr , elem . Sha256 ) ) } log . Debug ( " " , tm . Message ) log . Debug ( " " , tm . Signature ) return tm , nil }
Measure implements the attestation reports generic Measure interface to be called
as a plugin during attestation report generation
Measure implements the attestation reports generic Measure interface to be called as a plugin during attestation report generation
// If the IMA is used, not the final PCR value is sent but instead // a list of the kernel modules which are extended during verification // to result in the final value // Find the IMA PCR in the TPM Measurement