Skip to content

Commit

Permalink
ca: remove duplicate oid usage
Browse files Browse the repository at this point in the history
  • Loading branch information
3u13r authored and katexochen committed Feb 8, 2024
1 parent e345847 commit 830d808
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 16 deletions.
32 changes: 16 additions & 16 deletions internal/attestation/snp/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,22 @@ var (

chipIDOID = append(rootOID, 32)

committedTCBPartsBlSplOID = append(rootOID, 32)
committedTCBPartsSnpSplOID = append(rootOID, 33)
committedTCBPartsTeeSplOID = append(rootOID, 34)
committedTCBPartsUcodeSplOID = append(rootOID, 35)

currentBuildOID = append(rootOID, 36)
currentMinorOID = append(rootOID, 37)
currentMajorOID = append(rootOID, 38)
committedBuildOID = append(rootOID, 39)
committedMinorOID = append(rootOID, 40)
committedMajorOID = append(rootOID, 41)

launchTCBPartsBlSplOID = append(rootOID, 42)
launchTCBPartsSnpSplOID = append(rootOID, 43)
launchTCBPartsTeeSplOID = append(rootOID, 44)
launchTCBPartsUcodeSplOID = append(rootOID, 45)
committedTCBPartsBlSplOID = append(rootOID, 33)
committedTCBPartsSnpSplOID = append(rootOID, 34)
committedTCBPartsTeeSplOID = append(rootOID, 35)
committedTCBPartsUcodeSplOID = append(rootOID, 36)

currentBuildOID = append(rootOID, 37)
currentMinorOID = append(rootOID, 38)
currentMajorOID = append(rootOID, 39)
committedBuildOID = append(rootOID, 40)
committedMinorOID = append(rootOID, 41)
committedMajorOID = append(rootOID, 42)

launchTCBPartsBlSplOID = append(rootOID, 43)
launchTCBPartsSnpSplOID = append(rootOID, 44)
launchTCBPartsTeeSplOID = append(rootOID, 45)
launchTCBPartsUcodeSplOID = append(rootOID, 46)
)

type bigIntExtension struct {
Expand Down
26 changes: 26 additions & 0 deletions internal/attestation/snp/extensions_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package snp

import (
"testing"

"github.com/google/go-sev-guest/proto/sevsnp"
"github.com/stretchr/testify/require"
)

func TestClaimsToCertExtension(t *testing.T) {
require := require.New(t)
report := &sevsnp.Report{
Policy: 0x00000000000f0000,
}
exts, err := ClaimsToCertExtension(report)
require.NoError(err)

// Check that no OIDs are used multiple times
oidSet := make(map[string]struct{})
for _, ext := range exts {
oid := ext.Id.String()
_, ok := oidSet[oid]
require.False(ok, "OID %s used multiple times", oid)
oidSet[oid] = struct{}{}
}
}

0 comments on commit 830d808

Please sign in to comment.