Skip to content

Conversation

@abhiraj-ku
Copy link
Contributor

This PR consolidates PSA logic into the profiles package and removes PSA/CCA-specific COMID types to simplify and generalize the implementation. It reduces profile-specific coupling, and updates test fixtures accordingly, improving maintainability and extensibility for future profiles.

@abhiraj-ku abhiraj-ku force-pushed the impl-id-sign-id-ver branch 2 times, most recently from e8cb9a4 to 2554414 Compare January 29, 2026 14:52
Copy link
Contributor

@thomas-fossati thomas-fossati left a comment

Choose a reason for hiding this comment

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

Looks great. Thanks for all your careful work!

I was expecting this PR to contain the PSA-08 implementation and was a little disoriented at first. I now understand that this is a significant restructuring of the existing logic (pre-08), and I'm looking forward to seeing the next steps!

Could you please fix the organisation of the commits and the messages? (In particular, I believe there are no new features here, so the feat label should not be used in the headings.

@abhiraj-ku
Copy link
Contributor Author

Hey Thomas, thanks for the review! You’re right, this PR is focused on restructuring existing logic, not new features. I’ll clean up the commit messages and squash/rewrite the commit history accordingly.

@@ -0,0 +1,122 @@
// Copyright 2021-2024 Contributors to the Veraison project.
Copy link
Contributor

Choose a reason for hiding this comment

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

The Headers in all files should be reflected upto 2026, now!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok i'll fix this and amend with psa commit

@yogeshbdeshpande
Copy link
Contributor

Started reviewing, will finish by end of day today!

@abhiraj-ku
Copy link
Contributor Author

abhiraj-ku commented Feb 3, 2026

Started reviewing, will finish by end of day today!

Ok,sure

}

// Register PSA-specific ClassID factory (psa.impl-id)
// CBOR tag 560 is already registered for TaggedBytes in comid/cbor.go
Copy link
Contributor

Choose a reason for hiding this comment

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

@abhiraj-ku I do not see the tag 560 been applied as you are NOT instantiating ImplID as Tagged Bytes in the Methoid NewImplIDClassID).

Copy link
Contributor

@yogeshbdeshpande yogeshbdeshpande left a comment

Choose a reason for hiding this comment

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

The new Interface functions for Instatiating ClassID using ImplID needs to be re-written to claim that TaggedBytes are used instead:

for i := range implID {
implID[i] = byte(i)
}
class := comid.NewClassBytes(implID)
Copy link
Contributor

Choose a reason for hiding this comment

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

This approach should be used when instantiating ClassID using Implementation ID

Copy link
Contributor

@yogeshbdeshpande yogeshbdeshpande left a comment

Choose a reason for hiding this comment

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

see further comments...

Copy link
Contributor

@setrofim setrofim left a comment

Choose a reason for hiding this comment

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

A note on commit messages:

  • do not capitalize the classification tag, so feat not Feat (note: you generally should capilize the initial word of the title, but classification tags are an exception, in the same way as you wouldn't capilize a variable name (if it's not capitalized in code) even if its the first word in a sentence.)
  • Keep the commit message titles (i.e. the inital line of the message) short, and use the commit body to fully describe the change, rather than trying to put everything into the commit title. (note: the common advice is the 50/72 rule, i.e. the title should be at most 50 characters, and the commit body should be formatted to 72-column lines.

comid/classid.go Outdated
}
}

type IClassIDValue interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this moved below SetUUID and GetUUID mothod definitions? Please revert to the original location.

comid/classid.go Outdated
// RegisterClassIDFactory registers a new IClassIDValue factory without registering
// a CBOR tag. Use this when the underlying CBOR tag is already registered (e.g., for
// profile-specific types that reuse existing CBOR tags).
func RegisterClassIDFactory(factory IClassIDFactory) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem right. A CBOR tag identifies the type. You cannot have the same tag map to different types. And a profile cannot "re-use" a tag for a different type. This will cause problems.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed—one tag must map to one type. The factory was a leftover from exploring profile conveniences; I’ve removed it and will push the fix with the other requested changes

Add(MustNewPKIXBase64Key(TestECPubKey))

result := keys.String()
assert.Contains(t, result, "[")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what these asserts are testing? Since all the inputs are known, you should be comparing to the exact expected output, not just that output features square brackets.

}
}

func Test_UEID_Empty(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func Test_UEID_Empty(t *testing.T) {
func TestUEID_Empty(t *testing.T) {

// NOTE: Test skipped because CBOR test files contain PSA-specific types (tag 601)
// that are now registered only in profiles/psa, not in the base comid package.
// TODO: Regenerate CBOR test files using generic types (UUID, bytes, etc.)
t.Skip("Test uses PSA-specific CBOR tags in test data; regenerate with generic types")
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of skipping, you should update the offending inputs to not include the now-obsolete types (since which just need a valid CoRIM for this, you can replace them with any valid alteranative, e.g. a UUID instead of PSA ImplID).


var decoded UnsignedCorim
err = decoded.FromJSON(jsonData)
assert.NoError(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

In addition to making sure that there is no error, you should also check to make sure that decoded is what you expect (i.e. you can do this by comparing some if its fields to the equivalents inside valid)

"github.com/veraison/corim/comid"
)

const ImplIDType = "psa.impl-id"
Copy link
Contributor

Choose a reason for hiding this comment

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

You should be getting rid of this type. The implementation ID should now be represented by TaggedBytes, not a custom type. The addtional validation should be done as on top of the type via the validation methods (which you are already doing).

This also means yo do not need the (broken) factory registration function above.


// TriplesExtensions carries PSA-specific fields and constraints for Triples
type TriplesExtensions struct {
PsaSwRelTriples *PsaSwRelTriples `cbor:"5,keyasint,omitempty" json:"psa-swrel-triples,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this field necessary? You should not be defining any extension fields -- you just want the extension for its validation methods. (Also, code point 5 clashes with domain-membership-triple-record define by the CoRIM draft).

comid/classid.go Outdated
Comment on lines 89 to 90
// The exact encoding is <CLASS_ID_TYPE> dependent. For the base implementation
// types it is
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// The exact encoding is <CLASS_ID_TYPE> dependent. For the base implementation
// types it is
// The exact encoding is <CLASS_ID_TYPE> dependent.

tv := MustHexDecode(t, "d90258582061636d652d696d706c656d656e746174696f6e2d69642d303030303030303031")

expected := b64TestImplID()
tv := MustHexDecode(t, "d90230582061636d652d696d706c656d656e746174696f6e2d69642d303030303030303031")
Copy link
Contributor

Choose a reason for hiding this comment

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

When the Implementation ID goes in the profile section of the corim repo, then the ImplID based ClassID test should also go their.

@@ -2,150 +2,3 @@
// SPDX-License-Identifier: Apache-2.0

package comid
Copy link
Contributor

Choose a reason for hiding this comment

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

I think, you forgot to delete the file, but just left a file with package comid.

Please check and delete this file completely.

}

// IMkeyFactory defines the signature for the factory functions that may be
// registred using RegisterMkeyType to provide a new implementation of the
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// registred using RegisterMkeyType to provide a new implementation of the
// registered using RegisterMkeyType to provide a new implementation of the

Copy link
Contributor

@yogeshbdeshpande yogeshbdeshpande left a comment

Choose a reason for hiding this comment

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

some more comments- will complete the review by end of the day today!!!

// ----- end of profile definition -----
// The following code demonstrates how the profile might be used.

// NOTE: Example_profile_unmarshal has been temporarily disabled because the test
Copy link
Contributor

Choose a reason for hiding this comment

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

Either create a github issue to track this pending work, or make sure you correct this before the submission of this Pull Request. Either way it is fine...

Copy link
Contributor

Choose a reason for hiding this comment

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

i think i need to replace PSA-specific types in the yaml test data with generic types(uuid for ex) that don't require separate registration, then regenerate the CBOR test files , right?

Yes essentially the old changes need to be removed and the current newly introduced types need to replace the same and then re-generate the CBOR from yaml files

}

func TestProfileManifest_Marshaling_UnMarshaling(t *testing.T) {
// NOTE: This test is skipped because it uses test data containing PSA-specific
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment, either create a new issue to complete the work or ensure this is complete and re-submit for the review!!

Copy link
Contributor

@yogeshbdeshpande yogeshbdeshpande left a comment

Choose a reason for hiding this comment

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

Completed review, some comments have been left for you to review.

Rest all Looks Good to me.

Once you complete these minor comments, I will Approve!!!!

Copy link
Contributor

@yogeshbdeshpande yogeshbdeshpande left a comment

Choose a reason for hiding this comment

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

see my response!!!

// ----- end of profile definition -----
// The following code demonstrates how the profile might be used.

// NOTE: Example_profile_unmarshal has been temporarily disabled because the test
Copy link
Contributor

Choose a reason for hiding this comment

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

i think i need to replace PSA-specific types in the yaml test data with generic types(uuid for ex) that don't require separate registration, then regenerate the CBOR test files , right?

Yes essentially the old changes need to be removed and the current newly introduced types need to replace the same and then re-generate the CBOR from yaml files

feat(profiles/psa): extract and consolidate PSA logic into profile package

Signed-off-by: Abhishek kumar <[email protected]>
@abhiraj-ku
Copy link
Contributor Author

@yogeshbdeshpande please check, i have pushed the changes

Copy link
Contributor

@yogeshbdeshpande yogeshbdeshpande left a comment

Choose a reason for hiding this comment

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

LGTM! I have reviewed the changes and thanks for incorporating comments!

Copy link
Contributor

@setrofim setrofim left a comment

Choose a reason for hiding this comment

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

Also minor nit: the "update class-ID tag from 600 to 560 in test fixtures" should be fixed-up into the prior commit. Test updates should be part of the same commit that necessitates them. (the title also lacks the conventional commits category tag)

@@ -69,16 +54,15 @@ func TestClassID_UnmarshalCBOR_UUID_OK(t *testing.T) {
}

func TestClassID_UnmarshalCBOR_ImplID_OK(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test should probably re named

Suggested change
func TestClassID_UnmarshalCBOR_ImplID_OK(t *testing.T) {
func TestClassID_UnmarshalCBOR_bytes_OK(t *testing.T) {

@@ -1,9 +1,10 @@
// Copyright 2023 Contributors to the Veraison project.
// Copyright 2026 Contributors to the Veraison project.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Copyright 2026 Contributors to the Veraison project.
// Copyright 2023-2026 Contributors to the Veraison project.


// RegisterMkeyFactory registers a new IMKeyValue factory without registering
// a CBOR tag. Use this when the underlying CBOR tag is already registered.
func RegisterMkeyFactory(factory IMkeyFactory) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

As stated in the earlier review, this should not exist. Registration of an new extension type must always be accompanied by a tag, otherwise CBOR decoding wont work.

(this should also not be necessary for this pull request, as you should not be registering any new key types).

@@ -1,4 +1,4 @@
// Copyright 2024 Contributors to the Veraison project.
// Copyright 2026 Contributors to the Veraison project.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Copyright 2026 Contributors to the Veraison project.
// Copyright 2024-2026 Contributors to the Veraison project.

@@ -1,4 +1,4 @@
// Copyright 2024 Contributors to the Veraison project.
// Copyright 2026 Contributors to the Veraison project.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Copyright 2026 Contributors to the Veraison project.
// Copyright 2024-2026 Contributors to the Veraison project.

if nb := len(t); nb != ImplIDSize {
return nil, fmt.Errorf("bad psa.impl-id: got %d bytes, want %d", nb, ImplIDSize)
}
implIDBytes = make([]byte, ImplIDSize)
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to be doing this inside every case -- you can just initialize the implIDBytes once at the beginning of the function, since it's always initialized to a 32-byte buffer, regardless of val


// Register PSA-specific Mkey type (psa.refval-id) with CBOR tag 601
// This registers both the CBOR tag and the factory
if err := comid.RegisterMkeyType(PSARefValIDTag, NewMkeyPSARefvalID); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

No. You should not be registering a new type here. I'm not sure where you're getting this from?

Section 3.3 of the spec states that the value of the mkey MUST be "psa.software-component", i.e. it's a string (which is one of the standard CoRIM types for mkey) with a specific value. This is something you should be validating as part of your ValidTriples below, but you don't need to be registering a type for it.

func (o TriplesExtensions) ValidTriples(triples *comid.Triples) error {
// Validate Reference Values (Section 3.3)
if triples.ReferenceValues != nil {
refVals := (*extensions.Collection[comid.ValueTriple, *comid.ValueTriple])(triples.ReferenceValues)
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be necessary. The for loop can just be for i, refVal := range triples.ReferenceValues.Values {

}

// Access the Measurements collection
measurements := (*extensions.Collection[comid.Measurement, *comid.Measurement])(&refVal.Measurements)
Copy link
Contributor

Choose a reason for hiding this comment

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

again, this is not necessary, you can just directly use refVal.Measurements.Values

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should be able to just completely get rid of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants