| 1 |
package cmd |
| 2 |
|
| 3 |
import ( |
| 4 |
sabi "github.com/google/go-sev-guest/abi" |
| 5 |
spb "github.com/google/go-sev-guest/proto/sevsnp" |
| 6 |
"github.com/google/go-sev-guest/validate" |
| 7 |
sv "github.com/google/go-sev-guest/verify" |
| 8 |
) |
| 9 |
|
| 10 |
// The policy on GCE is to allow SMT, and eventually MigrateMA, but no debug bit. |
| 11 |
var defaultSevSnpGuestPolicy = sabi.SnpPolicy{ |
| 12 |
SMT: true, |
| 13 |
MigrateMA: true, |
| 14 |
} |
| 15 |
|
| 16 |
// verifySnpOpts allows for customizing the functionality of VerifyAttestation's SEV-SNP verification. |
| 17 |
type verifySnpOpts struct { |
| 18 |
Validation *validate.Options |
| 19 |
Verification *sv.Options |
| 20 |
} |
| 21 |
|
| 22 |
// sevSnpDefaultValidateOpts returns a default validation policy for SEV-SNP attestation reports on GCE. |
| 23 |
func sevSnpDefaultValidateOpts(tpmNonce []byte) *validate.Options { |
| 24 |
policy := &validate.Options{GuestPolicy: defaultSevSnpGuestPolicy} |
| 25 |
policy.ReportData = make([]byte, sabi.ReportDataSize) |
| 26 |
copy(policy.ReportData, tpmNonce) |
| 27 |
return policy |
| 28 |
} |
| 29 |
|
| 30 |
// verifySevSnpAttestation checks that the SEV-SNP attestation report matches expectations for the |
| 31 |
// product. |
| 32 |
func verifySevSnpAttestation(attestation *spb.Attestation, opts *verifySnpOpts) error { |
| 33 |
// Check that the report is signed by a valid AMD key. Do not check revocations. This must be |
| 34 |
// done before validation to ensure the certificates are filled in by the verify library. |
| 35 |
if err := sv.SnpAttestation(attestation, opts.Verification); err != nil { |
| 36 |
return err |
| 37 |
} |
| 38 |
// Check that the fields of the report are acceptable. |
| 39 |
return validate.SnpAttestation(attestation, opts.Validation) |
| 40 |
} |