From 091fe3e2d7a2649d80aafbc8cfcc16c9806e48ab Mon Sep 17 00:00:00 2001 From: Thomas Tendyck Date: Wed, 29 Mar 2023 10:52:57 +0200 Subject: [PATCH] measurements: compare to constants for clarity --- internal/attestation/measurements/measurements.go | 2 +- internal/attestation/vtpm/attestation.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/attestation/measurements/measurements.go b/internal/attestation/measurements/measurements.go index 859265940..26e057f9f 100644 --- a/internal/attestation/measurements/measurements.go +++ b/internal/attestation/measurements/measurements.go @@ -143,7 +143,7 @@ func (m *M) EqualTo(other M) bool { func (m *M) GetEnforced() []uint32 { var enforced []uint32 for idx, measurement := range *m { - if !measurement.ValidationOpt { + if measurement.ValidationOpt == Enforce { enforced = append(enforced, idx) } } diff --git a/internal/attestation/vtpm/attestation.go b/internal/attestation/vtpm/attestation.go index 96a1894a0..7a7cd72ef 100644 --- a/internal/attestation/vtpm/attestation.go +++ b/internal/attestation/vtpm/attestation.go @@ -227,7 +227,7 @@ func (v *Validator) Validate(ctx context.Context, attDocRaw []byte, nonce []byte } for idx, pcr := range v.expected { if !bytes.Equal(pcr.Expected[:], attDoc.Attestation.Quotes[quoteIdx].Pcrs.Pcrs[idx]) { - if !pcr.ValidationOpt { + if pcr.ValidationOpt == measurements.Enforce { return nil, fmt.Errorf("untrusted PCR value at PCR index %d", idx) } v.log.Warnf("Encountered untrusted PCR value at index %d", idx)