Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attestationreport: fix and better log output #181

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion attestationreport/attestationreport.go
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ func checkExtensionBuf(cert *x509.Certificate, oid string, buf []byte) (Result,
Got: hex.EncodeToString(ext.Value),
}, false
}
return Result{Success: false}, false
return Result{Success: true}, true
}
}

Expand Down
12 changes: 8 additions & 4 deletions attestationreport/snp.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ const (
func verifySnpMeasurements(snpM Measurement, nonce []byte, referenceValues []ReferenceValue,
) (*MeasurementResult, bool) {

log.Trace("Verifying SNP measurements")

result := &MeasurementResult{
Type: "SNP Result",
SnpResult: &SnpResult{},
Expand Down Expand Up @@ -154,6 +156,7 @@ func verifySnpMeasurements(snpM Measurement, nonce []byte, referenceValues []Ref

// Compare Measurements
if cmp := bytes.Compare(s.Measurement[:], snpReferenceValue.Sha384); cmp != 0 {
log.Trace("Failed to verify SNP reference value")
result.Artifacts = append(result.Artifacts,
DigestResult{
Name: snpReferenceValue.Name,
Expand All @@ -171,6 +174,7 @@ func verifySnpMeasurements(snpM Measurement, nonce []byte, referenceValues []Ref

ok = false
} else {
log.Trace("Successfully verified SNP reference value")
// As we previously checked, that the attestation report contains exactly one
// SNP Reference Value, we can set this here:
result.Artifacts = append(result.Artifacts,
Expand Down Expand Up @@ -481,25 +485,25 @@ func verifySnpExtensions(cert *x509.Certificate, report *snpreport) ([]Result, b

if r, ok = checkExtensionUint8(cert, "1.3.6.1.4.1.3704.1.3.2", uint8(tcb>>8)); !ok {
log.Tracef("SEV TEE Extension Check failed")
ok = false
success = false
}
results = append(results, r)

if r, ok = checkExtensionUint8(cert, "1.3.6.1.4.1.3704.1.3.3", uint8(tcb>>48)); !ok {
log.Tracef("SEV SNP Extension Check failed")
ok = false
success = false
}
results = append(results, r)

if r, ok = checkExtensionUint8(cert, "1.3.6.1.4.1.3704.1.3.8", uint8(tcb>>56)); !ok {
log.Tracef("SEV UCODE Extension Check failed")
ok = false
success = false
}
results = append(results, r)

if r, ok = checkExtensionBuf(cert, "1.3.6.1.4.1.3704.1.4", report.ChipId[:]); !ok {
log.Tracef("Chip ID Extension Check failed")
ok = false
success = false
}
results = append(results, r)

Expand Down
5 changes: 5 additions & 0 deletions attestationreport/snp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ package attestationreport
import (
"encoding/hex"
"testing"

"github.com/sirupsen/logrus"
)

func Test_verifySnpMeasurements(t *testing.T) {

logrus.SetLevel(logrus.TraceLevel)

type args struct {
snpM *Measurement
snpV []ReferenceValue
Expand Down
2 changes: 2 additions & 0 deletions attestationreport/sw.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (

func VerifySwMeasurements(swMeasurements []Measurement, refVals []ReferenceValue) ([]MeasurementResult, bool) {

log.Trace("Verifying SW measurements")

swMeasurementResults := make([]MeasurementResult, 0)
ok := true

Expand Down
2 changes: 2 additions & 0 deletions attestationreport/tdx.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ func parseECDSASignatureV4(buf *bytes.Buffer, sig *ECDSA256QuoteSignatureDataStr

func verifyTdxMeasurements(tdxM Measurement, nonce []byte, intelCache string, referenceValues []ReferenceValue) (*MeasurementResult, bool) {

log.Trace("Verifying TDX measurements")

var err error
result := &MeasurementResult{
Type: "TDX Result",
Expand Down
Loading