Skip to content

Commit c581cb6

Browse files
committed
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 <[email protected]>
1 parent ec01ace commit c581cb6

File tree

2 files changed

+3
-41
lines changed

2 files changed

+3
-41
lines changed

comid/svn.go

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ type SVN struct {
2020
}
2121

2222
// NewSVN creates a new SVN of the specified and value. The type must be one of
23-
// the strings defined by the spec ("exact-value", "min-value"), or has been
24-
// registered with RegisterSVNType().
23+
// the strings defined by the spec ("exact-value", "min-value").
2524
func NewSVN(val any, typ string) (*SVN, error) {
2625
factory, ok := svnValueRegister[typ]
2726
if !ok {
@@ -279,9 +278,8 @@ func convertToSVNUint64(val any) (uint64, error) {
279278
}
280279
}
281280

282-
// ISVNFactory defines the signature for the factory functions that may be
283-
// registred using RegisterSVNType to provide a new implementation of the
284-
// corresponding type choice. The factory function should create a new *SVN
281+
// ISVNFactory defines the signature for factory functions to create SVN types
282+
// supported by svn-type-choice. The factory function should create a new *SVN
285283
// with the underlying value created based on the provided input. The range of
286284
// valid inputs is up to the specific type choice implementation, however it
287285
// _must_ accept nil as one of the inputs, and return the Zero value for
@@ -293,26 +291,3 @@ var svnValueRegister = map[string]ISVNFactory{
293291
ExactValueType: NewTaggedSVN,
294292
MinValueType: NewTaggedMinSVN,
295293
}
296-
297-
// RegisterSVNType registers a new ISVNValue implementation
298-
// (created by the provided ISVNFactory) under the specified CBOR tag.
299-
func RegisterSVNType(tag uint64, factory ISVNFactory) error {
300-
301-
nilVal, err := factory(nil)
302-
if err != nil {
303-
return err
304-
}
305-
306-
typ := nilVal.Value.Type()
307-
if _, exists := svnValueRegister[typ]; exists {
308-
return fmt.Errorf("SVN type with name %q already exists", typ)
309-
}
310-
311-
if err := registerCOMIDTag(tag, nilVal.Value); err != nil {
312-
return err
313-
}
314-
315-
svnValueRegister[typ] = factory
316-
317-
return nil
318-
}

comid/svn_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"testing"
77

88
"github.com/stretchr/testify/assert"
9-
"github.com/stretchr/testify/require"
109
)
1110

1211
func Test_NewSVN(t *testing.T) {
@@ -171,18 +170,6 @@ func (o testSVNBadType) Type() string {
171170
return "min-value"
172171
}
173172

174-
func Test_RegisterSVNType(t *testing.T) {
175-
err := RegisterSVNType(32, newTestSVN)
176-
assert.EqualError(t, err, "tag 32 is already registered")
177-
178-
err = RegisterSVNType(99995, newTestSVNBadType)
179-
assert.EqualError(t, err, `SVN type with name "min-value" already exists`)
180-
181-
err = RegisterSVNType(99995, newTestSVN)
182-
require.NoError(t, err)
183-
184-
}
185-
186173
func Test_TaggedSVN_Equal_True(t *testing.T) {
187174
claim := TaggedSVN(7)
188175
ref := TaggedSVN(7)

0 commit comments

Comments
 (0)