2023-03-09 05:22:58 -05:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Package tpm reads measurements from a TPM.
|
|
|
|
package tpm
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/vtpm"
|
|
|
|
"github.com/edgelesssys/constellation/v2/measurement-reader/internal/sorted"
|
|
|
|
tpmClient "github.com/google/go-tpm-tools/client"
|
2023-07-07 07:17:58 -04:00
|
|
|
"github.com/google/go-tpm/legacy/tpm2"
|
2023-03-09 05:22:58 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// Measurements returns a sorted list of TPM PCR measurements.
|
|
|
|
func Measurements() ([]sorted.Measurement, error) {
|
|
|
|
m, err := vtpm.GetSelectedMeasurements(vtpm.OpenVTPM, tpmClient.FullPcrSel(tpm2.AlgSHA256))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-03-09 12:55:05 -05:00
|
|
|
return sorted.SortMeasurements(m, sorted.TPM), nil
|
2023-03-09 05:22:58 -05:00
|
|
|
}
|