mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-02 20:16:15 -04:00
attestation: print ordered measurement verification warnings and errors (#2237)
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
78fa921746
commit
103817a4a5
5 changed files with 184 additions and 25 deletions
|
@ -7,9 +7,9 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
package tdx
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/edgelesssys/constellation/v2/internal/attestation"
|
||||
|
@ -81,13 +81,12 @@ func (v *Validator) Validate(ctx context.Context, attDocRaw []byte, nonce []byte
|
|||
}
|
||||
|
||||
// Verify the quote against the expected measurements.
|
||||
for idx, ex := range v.expected {
|
||||
if !bytes.Equal(ex.Expected, tdMeasure[idx]) {
|
||||
if !ex.ValidationOpt {
|
||||
return nil, fmt.Errorf("untrusted TD measurement value at index %d", idx)
|
||||
}
|
||||
v.log.Warnf("Encountered untrusted TD measurement value at index %d", idx)
|
||||
}
|
||||
warnings, errs := v.expected.Compare(tdMeasure)
|
||||
for _, warning := range warnings {
|
||||
v.log.Warnf(warning)
|
||||
}
|
||||
if len(errs) > 0 {
|
||||
return nil, fmt.Errorf("measurement validation failed:\n%w", errors.Join(errs...))
|
||||
}
|
||||
|
||||
return attDoc.UserData, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue