Skip to content

Commit 95e3279

Browse files
committed
fix(kds, validate): address feedback from review
- fix lint errors reported by Ubuntu CI - make error messages in tests reader friendly Signed-off-by: Jagannathan Raman <jraman567@gmail.com>
1 parent 82c768a commit 95e3279

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

kds/kds.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ var (
7272
// TCBStructVersion1 is the version of the TCB structure for Turin
7373
TCBStructVersion1 = uint8(1)
7474

75-
// TCBHwIdLenVersion0 is the length of the hwID extension for TCB structVersion 0
76-
TCBHwIdLenVersion0 = uint8(64)
77-
// TCBHwIdLenVersion1 is the length of the hwID extension for TCB structVersion 1
78-
TCBHwIdLenVersion1 = uint8(8)
75+
// TCBHwIDLenVersion0 is the length of the hwID extension for TCB structVersion 0
76+
TCBHwIDLenVersion0 = uint8(64)
77+
// TCBHwIDLenVersion1 is the length of the hwID extension for TCB structVersion 1
78+
TCBHwIDLenVersion1 = uint8(8)
7979

8080
authorityKeyOid = asn1.ObjectIdentifier([]int{2, 5, 29, 35})
8181
// Short forms of the asn1 Object identifiers to use in map lookups, since []int are invalid key
@@ -393,7 +393,7 @@ func asn1OctetString(ext *pkix.Extension, field string, size int) ([]byte, error
393393
func kdsOidMapToExtensions(exts map[kdsOID]*pkix.Extension) (*Extensions, error) {
394394
var (
395395
result Extensions
396-
hwIdLen int
396+
hwIDLen int
397397
)
398398

399399
if err := asn1U8(exts[kdsStructVersion], "StructVersion", &result.StructVersion); err != nil {
@@ -404,15 +404,15 @@ func kdsOidMapToExtensions(exts map[kdsOID]*pkix.Extension) (*Extensions, error)
404404
}
405405
switch result.StructVersion {
406406
case TCBStructVersion0:
407-
hwIdLen = int(TCBHwIdLenVersion0)
407+
hwIDLen = int(TCBHwIDLenVersion0)
408408
case TCBStructVersion1:
409-
hwIdLen = int(TCBHwIdLenVersion1)
409+
hwIDLen = int(TCBHwIDLenVersion1)
410410
default:
411411
return nil, fmt.Errorf("unsupported TCB structVersion %d", result.StructVersion)
412412
}
413413
hwidExt, ok := exts[kdsHwid]
414414
if ok {
415-
octet, err := asn1OctetString(hwidExt, "HWID", hwIdLen)
415+
octet, err := asn1OctetString(hwidExt, "HWID", hwIDLen)
416416
if err != nil {
417417
return nil, err
418418
}
@@ -509,7 +509,7 @@ func VcekCertificateExtensions(cert *x509.Certificate) (*Extensions, error) {
509509
if exts.CspID != "" {
510510
return nil, fmt.Errorf("unexpected CSP_ID in VCEK certificate: %s", exts.CspID)
511511
}
512-
if len(exts.HWID) != int(TCBHwIdLenVersion0) && len(exts.HWID) != int(TCBHwIdLenVersion1) {
512+
if len(exts.HWID) != int(TCBHwIDLenVersion0) && len(exts.HWID) != int(TCBHwIDLenVersion1) {
513513
return nil, fmt.Errorf("missing HWID extension for VCEK certificate")
514514
}
515515
return exts, nil
@@ -599,7 +599,7 @@ func VCEKCertURL(productLine string, hwid []byte, tcb TCBVersion) string {
599599
parts := DecomposeTCBVersion(tcb)
600600
switch parts.Version {
601601
case TCBStructVersion1:
602-
hwidv1 := hwid[0:TCBHwIdLenVersion1]
602+
hwidv1 := hwid[0:TCBHwIDLenVersion1]
603603
return fmt.Sprintf("%s/%s?blSPL=%d&teeSPL=%d&snpSPL=%d&ucodeSPL=%d&fmcSPL=%d",
604604
productBaseURL(abi.VcekReportSigner, productLine),
605605
hex.EncodeToString(hwidv1),

validate/validate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ func tcbNeError(left, right partDescription) error {
431431
if ltcb == rtcb {
432432
return nil
433433
}
434-
return fmt.Errorf("the %s %x does not match the %s %x", left.desc, ltcb, right.desc, rtcb)
434+
return fmt.Errorf("the %s 0x%x does not match the %s 0x%x", left.desc, ltcb.TCB, right.desc, rtcb.TCB)
435435
}
436436

437437
// tcbGtError returns an error if wantLower is greater than (in part) wantHigher. It enforces

validate/validate_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ func TestValidateSnpAttestation(t *testing.T) {
418418
name: "rejected provisional by tcb",
419419
attestation: attestationcb1455,
420420
opts: &Options{ReportData: noncecb1455[:], GuestPolicy: abi.SnpPolicy{Debug: true}},
421-
wantErr: "the report's COMMITTED_TCB {0 9270000000007f00} does not match the report's CURRENT_TCB {0 9270000000007f1f}",
421+
wantErr: "the report's COMMITTED_TCB 0x9270000000007f00 does not match the report's CURRENT_TCB 0x9270000000007f1f",
422422
},
423423
{
424424
name: "accepted provisional by version",

0 commit comments

Comments
 (0)