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") } 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..6708fc9b 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) { @@ -83,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) @@ -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)