@@ -132,10 +132,14 @@ const (
132
132
// ReportVersion2 is set by the SNP API specification
133
133
// https://web.archive.org/web/20231222054111if_/http://www.amd.com/content/dam/amd/en/documents/epyc-technical-docs/specifications/56860.pdf
134
134
ReportVersion2 = 2
135
+ // MinSupportedReportVersion is the lowest attestation report version that this library supports.
136
+ MinSupportedReportVersion = 2
135
137
136
138
// ReportVersion3 is set by the SNP API specification
137
139
// https://www.amd.com/system/files/TechDocs/56860.pdf
138
140
ReportVersion3 = 3
141
+ // MaxSupportedReportVersion is the highest attestation report version that this library supports.
142
+ MaxSupportedReportVersion = 4
139
143
)
140
144
141
145
// CertTableHeaderEntry defines an entry of the beginning of an extended attestation report which
@@ -502,7 +506,7 @@ func ReportToProto(data []uint8) (*pb.Report, error) {
502
506
r .ReportedTcb = binary .LittleEndian .Uint64 (data [0x180 :0x188 ])
503
507
504
508
mbzLo := 0x188
505
- if r .Version = = ReportVersion3 {
509
+ if r .Version > = ReportVersion3 {
506
510
mbzLo = 0x18B
507
511
r .Cpuid1EaxFms = FmsToCpuid1Eax (data [0x188 ], data [0x189 ], data [0x18A ])
508
512
}
@@ -603,8 +607,8 @@ func ValidateReportFormat(r []byte) error {
603
607
}
604
608
605
609
version := binary .LittleEndian .Uint32 (r [0x00 :0x04 ])
606
- if version != ReportVersion2 && version != ReportVersion3 {
607
- return fmt .Errorf ("report version is: %d. Expected %d or %d" , version , ReportVersion2 , ReportVersion3 )
610
+ if version < MinSupportedReportVersion || version > MaxSupportedReportVersion {
611
+ return fmt .Errorf ("report version is: %d. Expected between %d and %d" , version , MinSupportedReportVersion , MaxSupportedReportVersion )
608
612
}
609
613
610
614
policy := binary .LittleEndian .Uint64 (r [0x08 :0x10 ])
@@ -649,7 +653,7 @@ func ReportToAbiBytes(r *pb.Report) ([]byte, error) {
649
653
binary .LittleEndian .PutUint64 (data [0x180 :0x188 ], r .ReportedTcb )
650
654
651
655
// Add CPUID information if this is a version 3 report.
652
- if r .Version = = ReportVersion3 {
656
+ if r .Version > = ReportVersion3 {
653
657
family , model , stepping := FmsFromCpuid1Eax (r .Cpuid1EaxFms )
654
658
data [0x188 ] = family
655
659
data [0x189 ] = model
0 commit comments