From ec01acea909dc6d90cd97677d63ebc3f41841fe5 Mon Sep 17 00:00:00 2001 From: Jagannathan Raman Date: Tue, 20 May 2025 09:33:27 -0400 Subject: [PATCH 1/3] fix(raw-int): add raw-int member to measurement-values-map Add raw-int member to measurement-values-map Signed-off-by: Jagannathan Raman --- comid/measurement.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/comid/measurement.go b/comid/measurement.go index 9ff21627..501aa8b1 100644 --- a/comid/measurement.go +++ b/comid/measurement.go @@ -355,6 +355,7 @@ type Mval struct { UUID *UUID `cbor:"10,keyasint,omitempty" json:"uuid,omitempty"` Name *string `cbor:"11,keyasint,omitempty" json:"name,omitempty"` IntegrityRegisters *IntegrityRegisters `cbor:"14,keyasint,omitempty" json:"integrity-registers,omitempty"` + RawInt *RawInt `cbor:"15,keyasint,omitempty" json:"raw-int,omitempty"` Extensions } @@ -442,8 +443,8 @@ func (o Mval) Valid() error { o.UUID == nil && o.Name == nil && o.IntegrityRegisters == nil && + o.RawInt == nil && o.Extensions.IsEmpty() { - return fmt.Errorf("no measurement value set") } From 5e33e6820407cdceece2f5e00866209143dc5557 Mon Sep 17 00:00:00 2001 From: Jagannathan Raman Date: Tue, 20 May 2025 10:48:32 -0400 Subject: [PATCH 2/3] fix(svn): remove extensibility of the SVN type SVN isn't an extensible type per the CoRIM spec below: https://ietf-rats-wg.github.io/draft-ietf-rats-corim/draft-ietf-rats-corim.html#name-security-version-number Remove extensibility to align with the spec. Signed-off-by: Jagannathan Raman --- comid/svn.go | 31 +++---------------------------- comid/svn_test.go | 45 --------------------------------------------- 2 files changed, 3 insertions(+), 73 deletions(-) diff --git a/comid/svn.go b/comid/svn.go index 38654dd7..c7d5dd21 100644 --- a/comid/svn.go +++ b/comid/svn.go @@ -20,8 +20,7 @@ type SVN struct { } // NewSVN creates a new SVN of the specified and value. The type must be one of -// the strings defined by the spec ("exact-value", "min-value"), or has been -// registered with RegisterSVNType(). +// the strings defined by the spec ("exact-value", "min-value"). func NewSVN(val any, typ string) (*SVN, error) { factory, ok := svnValueRegister[typ] if !ok { @@ -279,9 +278,8 @@ func convertToSVNUint64(val any) (uint64, error) { } } -// ISVNFactory defines the signature for the factory functions that may be -// registred using RegisterSVNType to provide a new implementation of the -// corresponding type choice. The factory function should create a new *SVN +// ISVNFactory defines the signature for factory functions to create SVN types +// supported by svn-type-choice. The factory function should create a new *SVN // with the underlying value created based on the provided input. The range of // valid inputs is up to the specific type choice implementation, however it // _must_ accept nil as one of the inputs, and return the Zero value for @@ -293,26 +291,3 @@ var svnValueRegister = map[string]ISVNFactory{ ExactValueType: NewTaggedSVN, MinValueType: NewTaggedMinSVN, } - -// RegisterSVNType registers a new ISVNValue implementation -// (created by the provided ISVNFactory) under the specified CBOR tag. -func RegisterSVNType(tag uint64, factory ISVNFactory) error { - - nilVal, err := factory(nil) - if err != nil { - return err - } - - typ := nilVal.Value.Type() - if _, exists := svnValueRegister[typ]; exists { - return fmt.Errorf("SVN type with name %q already exists", typ) - } - - if err := registerCOMIDTag(tag, nilVal.Value); err != nil { - return err - } - - svnValueRegister[typ] = factory - - return nil -} diff --git a/comid/svn_test.go b/comid/svn_test.go index b8876720..0ceae2b3 100644 --- a/comid/svn_test.go +++ b/comid/svn_test.go @@ -6,7 +6,6 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func Test_NewSVN(t *testing.T) { @@ -139,50 +138,6 @@ func TestSVN_JSON(t *testing.T) { } -type testSVN uint64 - -func newTestSVN(_ any) (*SVN, error) { - v := testSVN(7) - return &SVN{&v}, nil -} - -func (o testSVN) Type() string { - return "test-value" -} - -func (o testSVN) String() string { - return "test" -} - -func (o testSVN) Valid() error { - return nil -} - -type testSVNBadType struct { - testSVN -} - -func newTestSVNBadType(_ any) (*SVN, error) { - v := testSVNBadType{testSVN(7)} - return &SVN{&v}, nil -} - -func (o testSVNBadType) Type() string { - return "min-value" -} - -func Test_RegisterSVNType(t *testing.T) { - err := RegisterSVNType(32, newTestSVN) - assert.EqualError(t, err, "tag 32 is already registered") - - err = RegisterSVNType(99995, newTestSVNBadType) - assert.EqualError(t, err, `SVN type with name "min-value" already exists`) - - err = RegisterSVNType(99995, newTestSVN) - require.NoError(t, err) - -} - func Test_TaggedSVN_Equal_True(t *testing.T) { claim := TaggedSVN(7) ref := TaggedSVN(7) From 027318bb1eca2d21b27c1d60dffbd32562da461f Mon Sep 17 00:00:00 2001 From: Jagannathan Raman Date: Tue, 20 May 2025 11:18:22 -0400 Subject: [PATCH 3/3] fix(svn_test): rename "min" variable to avoid collision with built-in type Signed-off-by: Jagannathan Raman --- comid/svn_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/comid/svn_test.go b/comid/svn_test.go index 0ceae2b3..6708fc9b 100644 --- a/comid/svn_test.go +++ b/comid/svn_test.go @@ -82,8 +82,8 @@ func Test_NewSVN(t *testing.T) { } retMin, err := NewSVN(tv.Input, "min-value") - min := TaggedMinSVN(tv.Expected) - expected = SVN{&min} + minSVN := TaggedMinSVN(tv.Expected) + expected = SVN{&minSVN} if tv.Err != "" { assert.EqualError(t, err, tv.Err)