attestation: print ordered measurement verification warnings and errors (#2237)

Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
Daniel Weiße 2023-08-16 10:45:54 +02:00 committed by GitHub
parent 78fa921746
commit 103817a4a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 184 additions and 25 deletions

View file

@ -80,7 +80,7 @@ func TestValidate(t *testing.T) {
defer tpmCloser.Close()
issuer := NewIssuer(tpmOpen, tpmclient.AttestationKeyRSA, fakeGetInstanceInfo, logger.NewTest(t))
validator := NewValidator(testExpectedPCRs, fakeGetTrustedKey, fakeValidateCVM, nil)
validator := NewValidator(testExpectedPCRs, fakeGetTrustedKey, fakeValidateCVM, logger.NewTest(t))
nonce := []byte{1, 2, 3, 4}
challenge := []byte("Constellation")
@ -206,6 +206,10 @@ func TestValidate(t *testing.T) {
Expected: []byte{0xFF},
ValidationOpt: measurements.Enforce,
},
1: measurements.Measurement{
Expected: []byte{0xFF},
ValidationOpt: measurements.Enforce,
},
},
fakeGetTrustedKey,
fakeValidateCVM,
@ -214,6 +218,25 @@ func TestValidate(t *testing.T) {
nonce: nonce,
wantErr: true,
},
"untrusted WarnOnly PCRs": {
validator: NewValidator(
measurements.M{
0: measurements.Measurement{
Expected: []byte{0xFF},
ValidationOpt: measurements.WarnOnly,
},
1: measurements.Measurement{
Expected: []byte{0xFF},
ValidationOpt: measurements.WarnOnly,
},
},
fakeGetTrustedKey,
fakeValidateCVM,
logger.NewTest(t)),
attDoc: mustMarshalAttestation(attDoc, require),
nonce: nonce,
wantErr: false,
},
"no sha256 quote": {
validator: NewValidator(testExpectedPCRs, fakeGetTrustedKey, fakeValidateCVM, warnLog),
attDoc: mustMarshalAttestation(AttestationDocument{