Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comid: Add OVMF metadata to the Measurement type #114

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci-go-cover.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
name: Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: "1.19"
go-version: "1.20"
- name: Checkout code
uses: actions/checkout@v2
- name: Install mockgen
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: ci
on: [push, pull_request]
jobs:

# Test on various OS with default Go version.
# Test on various OS with the specified Go version.
tests:
name: Test on ${{matrix.os}}
runs-on: ${{ matrix.os }}
Expand All @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: "1.19"
go-version: "1.20"
- name: Checkout code
uses: actions/checkout@v2
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ name: linters
on: [push, pull_request]
jobs:

# Check linters on latest-ubuntu with default version of Go.
# Check linters on latest-ubuntu with specified version of Go.
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: "1.19"
go-version: "1.20"
- name: Checkout code
uses: actions/checkout@v2
- name: Install golangci-lint
run: |
go version
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.46.2
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.58.2
- name: Install mockgen
run: |
go install github.com/golang/mock/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion cocli/cmd/comidCreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func NewComidCreateCmd() *cobra.Command {
file name, all the template file names (when from different directories)
MUST be different.
`,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
if err := checkComidCreateArgs(); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cocli/cmd/comidDisplay.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewComidDisplayCmd() *cobra.Command {
cocli comid display --file=c1.cbor --file=c2.cbor --dir=comids
`,

RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
if err := checkComidDisplayArgs(); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cocli/cmd/comidValidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewComidValidateCmd() *cobra.Command {
cocli comid validate --file=c1.cbor --file=c2.cbor --dir=comids
`,

RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
if err := checkComidValidateArgs(); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cocli/cmd/corimCreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewCorimCreateCmd() *cobra.Command {
--output=corim.cbor
`,

RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
if err := checkCorimCreateArgs(); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cocli/cmd/corimDisplay.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func NewCorimDisplayCmd() *cobra.Command {
cocli corim display --file yet-another-signed-corim.cbor --show-tags
`,

RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
if err := checkCorimDisplayArgs(); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cocli/cmd/corimExtract.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewCorimExtractCmd() *cobra.Command {
--output-dir=my-dir
`,

RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
if err := checkCorimExtractArgs(); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cocli/cmd/corimSign.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func NewCorimSignCmd() *cobra.Command {
--output=signed-corim.cbor
`,

RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
if err := checkCorimSignArgs(); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cocli/cmd/corimSubmit.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func NewCorimSubmitCmd(submitter ISubmitter) *cobra.Command {
--media-type="application/corim-unsigned+cbor; profile=http://arm.com/psa/iot/1"
`,

RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {

if err := checkSubmitArgs(); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cocli/cmd/corimVerify.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewCorimVerifyCmd() *cobra.Command {
cocli corim verify --file=signed-corim.cbor --key=key.jwk
`,

RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
if err := checkCorimVerifyArgs(); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cocli/cmd/cotsCreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func NewCotsCreateCtsCmd() *cobra.Command {
--output=cots.cbor
`,

RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
if err := checkctsCreateCtsArgs(); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cocli/cmd/cotsDisplay.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewCotsDisplayCmd() *cobra.Command {

`,

RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
if err := checkCotsDisplayArgs(); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion comid/classid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ func Test_TaggedInt(t *testing.T) {

type testClassID [4]byte

func newTestClassID(val any) (*ClassID, error) {
func newTestClassID(_ any) (*ClassID, error) {
return &ClassID{&testClassID{0x74, 0x65, 0x73, 0x74}}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion comid/cryptokey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ func Test_NewCryptoKey_negative(t *testing.T) {

type testCryptoKey [4]byte

func newTestCryptoKey(val any) (*CryptoKey, error) {
func newTestCryptoKey(_ any) (*CryptoKey, error) {
return &CryptoKey{&testCryptoKey{0x74, 0x64, 0x73, 0x74}}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion comid/entity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ type testEntityNameBadType struct {
testEntityName
}

func newTestEntityNameBadType(val any) (*EntityName, error) {
func newTestEntityNameBadType(_ any) (*EntityName, error) {
v := testEntityNameBadType{testEntityName(7)}
return &EntityName{&v}, nil
}
Expand Down
10 changes: 5 additions & 5 deletions comid/extensions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ type TestExtension struct {
TestFlag *bool
}

func (o *TestExtension) ConstrainComid(v *Comid) error {
func (o *TestExtension) ConstrainComid(_ *Comid) error {
return errors.New("invalid")
}

func (o *TestExtension) ValidTriples(v *Triples) error {
func (o *TestExtension) ValidTriples(_ *Triples) error {
return errors.New("invalid")
}

func (o *TestExtension) ConstrainMval(v *Mval) error {
func (o *TestExtension) ConstrainMval(_ *Mval) error {
return errors.New("invalid")
}

func (o *TestExtension) ConstrainFlagsMap(v *FlagsMap) error {
func (o *TestExtension) ConstrainFlagsMap(_ *FlagsMap) error {
return errors.New("invalid")
}

func (o *TestExtension) ConstrainEntity(v *Entity) error {
func (o *TestExtension) ConstrainEntity(_ *Entity) error {
return errors.New("invalid")
}

Expand Down
4 changes: 2 additions & 2 deletions comid/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

type testGroup uint64

func newTestGroup(val any) (*Group, error) {
func newTestGroup(_ any) (*Group, error) {
v := testGroup(7)
return &Group{&v}, nil
}
Expand All @@ -37,7 +37,7 @@ type testGroupBadType struct {
testGroup
}

func newTestGroupBadType(val any) (*Group, error) {
func newTestGroupBadType(_ any) (*Group, error) {
v := testGroupBadType{testGroup(7)}
return &Group{&v}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion comid/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestInstance_SetGetUEID_OK(t *testing.T) {

type testInstance string

func newTestInstance(val any) (*Instance, error) {
func newTestInstance(_ any) (*Instance, error) {
ret := testInstance("test")
return &Instance{&ret}, nil
}
Expand Down
31 changes: 17 additions & 14 deletions comid/measurement.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"github.com/veraison/corim/extensions"
"github.com/veraison/eat"
"github.com/veraison/swid"
"github.com/virtee/sev-snp-measure-go/ovmf"
)

const MaxUint64 = ^uint64(0)
Expand All @@ -26,7 +27,7 @@
}

// NewMkey creates a new Mkey of the specfied type using the provided value.
func NewMkey(val any, typ string) (*Mkey, error) {
func NewMkey(_ any, typ string) (*Mkey, error) {
factory, ok := mkeyValueRegister[typ]
if !ok {
return nil, fmt.Errorf("unexpected measurement key type: %q", typ)
Expand Down Expand Up @@ -343,18 +344,19 @@

// Mval stores a measurement-values-map with JSON and CBOR serializations.
type Mval struct {
Ver *Version `cbor:"0,keyasint,omitempty" json:"version,omitempty"`
SVN *SVN `cbor:"1,keyasint,omitempty" json:"svn,omitempty"`
Digests *Digests `cbor:"2,keyasint,omitempty" json:"digests,omitempty"`
Flags *FlagsMap `cbor:"3,keyasint,omitempty" json:"flags,omitempty"`
RawValue *RawValue `cbor:"4,keyasint,omitempty" json:"raw-value,omitempty"`
RawValueMask *[]byte `cbor:"5,keyasint,omitempty" json:"raw-value-mask,omitempty"`
MACAddr *MACaddr `cbor:"6,keyasint,omitempty" json:"mac-addr,omitempty"`
IPAddr *net.IP `cbor:"7,keyasint,omitempty" json:"ip-addr,omitempty"`
SerialNumber *string `cbor:"8,keyasint,omitempty" json:"serial-number,omitempty"`
UEID *eat.UEID `cbor:"9,keyasint,omitempty" json:"ueid,omitempty"`
UUID *UUID `cbor:"10,keyasint,omitempty" json:"uuid,omitempty"`
IntegrityRegisters *IntegrityRegisters `cbor:"14,keyasint,omitempty" json:"integrity-registers,omitempty"`
Ver *Version `cbor:"0,keyasint,omitempty" json:"version,omitempty"`
SVN *SVN `cbor:"1,keyasint,omitempty" json:"svn,omitempty"`
Digests *Digests `cbor:"2,keyasint,omitempty" json:"digests,omitempty"`
Flags *FlagsMap `cbor:"3,keyasint,omitempty" json:"flags,omitempty"`
RawValue *RawValue `cbor:"4,keyasint,omitempty" json:"raw-value,omitempty"`
RawValueMask *[]byte `cbor:"5,keyasint,omitempty" json:"raw-value-mask,omitempty"`
MACAddr *MACaddr `cbor:"6,keyasint,omitempty" json:"mac-addr,omitempty"`
IPAddr *net.IP `cbor:"7,keyasint,omitempty" json:"ip-addr,omitempty"`
SerialNumber *string `cbor:"8,keyasint,omitempty" json:"serial-number,omitempty"`
UEID *eat.UEID `cbor:"9,keyasint,omitempty" json:"ueid,omitempty"`
UUID *UUID `cbor:"10,keyasint,omitempty" json:"uuid,omitempty"`
IntegrityRegisters *IntegrityRegisters `cbor:"14,keyasint,omitempty" json:"integrity-registers,omitempty"`
OvmfMetadata *ovmf.MetadataWrapper `cbor:"15,keyasint,omitempty" json:"ovmf-metadata,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be done as extension work, not natively inside CoRIM.

Extensions
}

Expand Down Expand Up @@ -388,7 +390,7 @@
return encoding.SerializeStructToJSON(o)
}

func (o Mval) Valid() error {

Check failure on line 393 in comid/measurement.go

View workflow job for this annotation

GitHub Actions / Lint

hugeParam: o is heavy (120 bytes); consider passing it by pointer (gocritic)
if o.Ver == nil &&
o.SVN == nil &&
o.Digests == nil &&
Expand All @@ -400,7 +402,8 @@
o.SerialNumber == nil &&
o.UEID == nil &&
o.UUID == nil &&
o.IntegrityRegisters == nil {
o.IntegrityRegisters == nil &&
o.OvmfMetadata == nil {
return fmt.Errorf("no measurement value set")
}

Expand Down Expand Up @@ -721,7 +724,7 @@
return o
}

func (o Measurement) Valid() error {

Check failure on line 727 in comid/measurement.go

View workflow job for this annotation

GitHub Actions / Lint

hugeParam: o is heavy (136 bytes); consider passing it by pointer (gocritic)
if o.Key != nil && o.Key.IsSet() {
if err := o.Key.Valid(); err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions comid/measurement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ func TestNewMkeyOID(t *testing.T) {

type testMkey [4]byte

func newTestMkey(val any) (*Mkey, error) {
func newTestMkey(_ any) (*Mkey, error) {
return &Mkey{&testMkey{0x74, 0x64, 0x73, 0x74}}, nil
}

Expand Down Expand Up @@ -552,7 +552,7 @@ func (o badMkey) Type() string {
return "uuid"
}

func newBadMkey(val any) (*Mkey, error) {
func newBadMkey(_ any) (*Mkey, error) {
return &Mkey{&badMkey{testMkey{0x74, 0x64, 0x73, 0x74}}}, nil
}

Expand Down
4 changes: 2 additions & 2 deletions comid/svn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func TestSVN_JSON(t *testing.T) {

type testSVN uint64

func newTestSVN(val any) (*SVN, error) {
func newTestSVN(_ any) (*SVN, error) {
v := testSVN(7)
return &SVN{&v}, nil
}
Expand All @@ -160,7 +160,7 @@ type testSVNBadType struct {
testSVN
}

func newTestSVNBadType(val any) (*SVN, error) {
func newTestSVNBadType(_ any) (*SVN, error) {
v := testSVNBadType{testSVN(7)}
return &SVN{&v}, nil
}
Expand Down
1 change: 1 addition & 0 deletions comid/test_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var (
TestMKey uint64 = 700
TestCCALabel = "cca-platform-config"

// #nosec G101
TestECPrivKey = `-----BEGIN EC PRIVATE KEY-----
MHcCAQEEICAm3+mCCDTMuzKqfZso9NT8ur9U9GjuUQ/lNEJvwRFMoAoGCCqGSM49
AwEHoUQDQgAEW1BvqF+/ry8BWa7ZEMU1xYYHEQ8BlLT4MFHOaO+ICTtIvrEeEpr/
Expand Down
2 changes: 1 addition & 1 deletion corim/entity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ type testEntityNameBadType struct {
testEntityName
}

func newTestEntityNameBadType(val any) (*EntityName, error) {
func newTestEntityNameBadType(_ any) (*EntityName, error) {
v := testEntityNameBadType{testEntityName(7)}
return &EntityName{&v}, nil
}
Expand Down
4 changes: 2 additions & 2 deletions corim/extensions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ func (o TestExtensions) ConstrainEntity(ent *Entity) error {
return nil
}

func (o TestExtensions) ConstrainCorim(c *UnsignedCorim) error {
func (o TestExtensions) ConstrainCorim(_ *UnsignedCorim) error {
return errors.New("invalid")
}

func (o TestExtensions) ConstrainSigner(s *Signer) error {
func (o TestExtensions) ConstrainSigner(_ *Signer) error {
return errors.New("invalid")
}

Expand Down
11 changes: 6 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
module github.com/veraison/corim

go 1.18
go 1.20

require (
github.com/fxamacker/cbor/v2 v2.5.0
github.com/golang/mock v1.6.0
github.com/google/uuid v1.3.0
github.com/google/uuid v1.3.1
github.com/lestrrat-go/jwx/v2 v2.0.8
github.com/spf13/afero v1.9.2
github.com/spf13/cast v1.4.1
github.com/spf13/cobra v1.2.1
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.9.0
github.com/stretchr/testify v1.8.2
github.com/stretchr/testify v1.8.4
github.com/veraison/apiclient v0.2.1-0.20240531100343-8a3a730a1e94
github.com/veraison/eat v0.0.0-20210331113810-3da8a4dd42ff
github.com/veraison/go-cose v1.1.1-0.20230825153510-da0f9a62ade7
github.com/veraison/swid v1.1.1-0.20230911094910-8ffdd07a22ca
github.com/virtee/sev-snp-measure-go v0.0.0-20240530153610-e6e8dc9b6877
)

require (
Expand All @@ -26,7 +27,7 @@ require (
github.com/goccy/go-json v0.9.11 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/lestrrat-go/blackmagic v1.0.1 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/httprc v1.0.4 // indirect
Expand Down
Loading
Loading