-
Notifications
You must be signed in to change notification settings - Fork 32
feat: changed profile identifiers from HTTP URLs to tag URIs (RFC 4151) #223
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
Open
Sukuna0007Abhi
wants to merge
2
commits into
veraison:main
Choose a base branch
from
Sukuna0007Abhi:working
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+452
−4
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # CCA (Confidential Computing Architecture) Profiles | ||
|
|
||
| This package defines CCA profile identifiers using the tag URI scheme as specified in [RFC 4151](https://tools.ietf.org/html/rfc4151). | ||
|
|
||
| ## Profile Identifiers | ||
|
|
||
| Three profile identifiers are defined: | ||
|
|
||
| 1. **CCA Token Profile** | ||
| ``` | ||
| tag:arm.com,2025:cca-token | ||
| ``` | ||
| Used for CCA attestation tokens. | ||
|
|
||
| 2. **CCA Platform Endorsements Profile** | ||
| ``` | ||
| tag:arm.com,2025:cca-endorsements | ||
| ``` | ||
| Used for CCA platform endorsements. | ||
|
|
||
| 3. **CCA Realm Endorsements Profile** | ||
| ``` | ||
| tag:arm.com,2025:cca-realm-endorsements | ||
| ``` | ||
| Used for CCA realm endorsements. | ||
|
|
||
| ## Usage | ||
|
|
||
| ```go | ||
| import "github.com/veraison/corim/comid/cca" | ||
|
|
||
| func example() { | ||
| // Use CCA Token Profile | ||
| tokenProfile := cca.TokenProfileID | ||
|
|
||
| // Use CCA Platform Endorsements Profile | ||
| platformProfile := cca.EndorsementsProfileID | ||
|
|
||
| // Use CCA Realm Endorsements Profile | ||
| realmProfile := cca.RealmEndorsementsProfileID | ||
| } | ||
| ``` | ||
|
|
||
| ## Tag URI Format | ||
|
|
||
| The tag URIs follow RFC 4151 format: | ||
| - Authority: `arm.com` - representing Arm Limited | ||
| - Date: `2025` - year of profile definition | ||
| - Specific ID: One of `cca-token`, `cca-endorsements`, or `cca-realm-endorsements` | ||
|
|
||
| These tag URIs are used instead of HTTP URLs to avoid accidental dereferencing while maintaining unique identification. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| // Copyright 2025 Contributors to the Veraison project. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package cca | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "regexp" | ||
|
|
||
| "github.com/veraison/eat" | ||
| ) | ||
|
|
||
| // tagURIPattern validates RFC 4151 tag URI format | ||
| // tag:authority,date:specific | ||
| var tagURIPattern = regexp.MustCompile(`^tag:[a-zA-Z0-9\.\-]+,\d{4}(-(0[1-9]|1[0-2])(-(0[1-9]|[12][0-9]|3[01]))?)?:.+$`) | ||
|
|
||
| // validateTagURI checks if the given string is a valid tag URI according to RFC 4151 | ||
| func validateTagURI(uri string) error { | ||
| if !tagURIPattern.MatchString(uri) { | ||
| return fmt.Errorf("invalid tag URI format: %q (expected format: tag:authority,date:specific)", uri) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| var ( | ||
| // CCA Token Profile ID using tag URI scheme | ||
| TokenProfileID *eat.Profile | ||
|
|
||
| // CCA Platform Endorsements Profile ID using tag URI scheme | ||
| EndorsementsProfileID *eat.Profile | ||
|
|
||
| // CCA Realm Endorsements Profile ID using tag URI scheme | ||
| RealmEndorsementsProfileID *eat.Profile | ||
| ) | ||
|
|
||
| func init() { | ||
| var err error | ||
|
|
||
| // Validate and create Token Profile | ||
| if err = validateTagURI("tag:arm.com,2025:cca-token"); err != nil { | ||
| panic(err) | ||
| } | ||
| TokenProfileID, err = eat.NewProfile("tag:arm.com,2025:cca-token") | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| // Validate and create Endorsements Profile | ||
| if err = validateTagURI("tag:arm.com,2025:cca-endorsements"); err != nil { | ||
| panic(err) | ||
| } | ||
| EndorsementsProfileID, err = eat.NewProfile("tag:arm.com,2025:cca-endorsements") | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| // Validate and create Realm Endorsements Profile | ||
| if err = validateTagURI("tag:arm.com,2025:cca-realm-endorsements"); err != nil { | ||
| panic(err) | ||
| } | ||
| RealmEndorsementsProfileID, err = eat.NewProfile("tag:arm.com,2025:cca-realm-endorsements") | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| // Copyright 2025 Contributors to the Veraison project. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package cca | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| "github.com/veraison/eat" | ||
| ) | ||
|
|
||
| func TestCCAProfiles_URIFormat(t *testing.T) { | ||
| // Verify Token Profile ID | ||
| tokenURI, err := TokenProfileID.Get() | ||
| require.NoError(t, err) | ||
| assert.Equal(t, | ||
| "tag:arm.com,2025:cca-token", | ||
| tokenURI, | ||
| "TokenProfileID should use tag URI scheme", | ||
| ) | ||
|
|
||
| // Verify Platform Endorsements Profile ID | ||
| endorsementsURI, err := EndorsementsProfileID.Get() | ||
| require.NoError(t, err) | ||
| assert.Equal(t, | ||
| "tag:arm.com,2025:cca-endorsements", | ||
| endorsementsURI, | ||
| "EndorsementsProfileID should use tag URI scheme", | ||
| ) | ||
|
|
||
| // Verify Realm Endorsements Profile ID | ||
| realmURI, err := RealmEndorsementsProfileID.Get() | ||
| require.NoError(t, err) | ||
| assert.Equal(t, | ||
| "tag:arm.com,2025:cca-realm-endorsements", | ||
| realmURI, | ||
| "RealmEndorsementsProfileID should use tag URI scheme", | ||
| ) | ||
| } | ||
|
|
||
| func TestCCAProfiles_Validation(t *testing.T) { | ||
| // Test valid tag URIs can be created | ||
| tests := []struct { | ||
| name string | ||
| uri string | ||
| }{ | ||
| { | ||
| name: "Token Profile", | ||
| uri: "tag:arm.com,2025:cca-token", | ||
| }, | ||
| { | ||
| name: "Platform Endorsements Profile", | ||
| uri: "tag:arm.com,2025:cca-endorsements", | ||
| }, | ||
| { | ||
| name: "Realm Endorsements Profile", | ||
| uri: "tag:arm.com,2025:cca-realm-endorsements", | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| profile, err := eat.NewProfile(tt.uri) | ||
| require.NoError(t, err) | ||
| require.NotNil(t, profile) | ||
| profileURI, err := profile.Get() | ||
| require.NoError(t, err) | ||
| assert.Equal(t, tt.uri, profileURI) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestCCAProfiles_InvalidURIs(t *testing.T) { | ||
| // Test invalid URIs are rejected by validation | ||
| tests := []struct { | ||
| name string | ||
| uri string | ||
| }{ | ||
| { | ||
| name: "HTTP URL instead of tag URI", | ||
| uri: "http://arm.com/cca-token", | ||
| }, | ||
| { | ||
| name: "Missing date", | ||
| uri: "tag:arm.com:cca-token", | ||
| }, | ||
| { | ||
| name: "Invalid date format", | ||
| uri: "tag:arm.com,abcd:cca-token", | ||
| }, | ||
| { | ||
| name: "Empty specific part", | ||
| uri: "tag:arm.com,2025:", | ||
| }, | ||
| { | ||
| name: "Not a tag URI", | ||
| uri: "urn:example:cca-token", | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| err := validateTagURI(tt.uri) | ||
| assert.Error(t, err, "Expected validation error for URI: %s", tt.uri) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestCCAProfiles_Equality(t *testing.T) { | ||
| // Test profile equality | ||
| token1, err := eat.NewProfile("tag:arm.com,2025:cca-token") | ||
| require.NoError(t, err) | ||
| token2, err := eat.NewProfile("tag:arm.com,2025:cca-token") | ||
| require.NoError(t, err) | ||
| endorsements, err := eat.NewProfile("tag:arm.com,2025:cca-endorsements") | ||
| require.NoError(t, err) | ||
|
|
||
| // Same profile URIs should be equal | ||
| assert.Equal(t, token1, token2) | ||
|
|
||
| // Different profile URIs should not be equal | ||
| assert.NotEqual(t, token1, endorsements) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # PSA (Platform Security Architecture) Profiles | ||
|
|
||
| This package defines PSA profile identifiers using the tag URI scheme as specified in [RFC 4151](https://tools.ietf.org/html/rfc4151). | ||
|
|
||
| ## Profile Identifiers | ||
|
|
||
| Two profile identifiers are defined: | ||
|
|
||
| 1. **PSA Token Profile** | ||
| ``` | ||
| tag:trustedcomputinggroup.org,2025:psa-token | ||
| ``` | ||
| Used for PSA attestation tokens as defined in [draft-tschofenig-rats-psa-token](https://datatracker.ietf.org/doc/html/draft-tschofenig-rats-psa-token). | ||
|
|
||
| 2. **PSA Platform Endorsements Profile** | ||
| ``` | ||
| tag:trustedcomputinggroup.org,2025:psa-endorsements | ||
| ``` | ||
| Used for PSA platform endorsements. | ||
|
|
||
| ## Usage | ||
|
|
||
| ```go | ||
| import "github.com/veraison/corim/comid/psa" | ||
|
|
||
| func example() { | ||
| // Use PSA Token Profile | ||
| tokenProfile := psa.TokenProfileID | ||
|
|
||
| // Use PSA Endorsements Profile | ||
| endorsementsProfile := psa.EndorsementsProfileID | ||
| } | ||
| ``` | ||
|
|
||
| ## Tag URI Format | ||
|
|
||
| The tag URIs follow RFC 4151 format: | ||
| - Authority: `trustedcomputinggroup.org` - representing the TCG organization | ||
| - Date: `2025` - year of profile definition | ||
| - Specific ID: Either `psa-token` or `psa-endorsements` | ||
|
|
||
| These tag URIs are used instead of HTTP URLs to avoid accidental dereferencing while maintaining unique identification. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // Copyright 2025 Contributors to the Veraison project. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package psa | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "regexp" | ||
|
|
||
| "github.com/veraison/eat" | ||
| ) | ||
|
|
||
| // tagURIPattern validates RFC 4151 tag URI format | ||
| // tag:authority,date:specific | ||
| var tagURIPattern = regexp.MustCompile(`^tag:[a-zA-Z0-9\.\-]+,\d{4}(-(0[1-9]|1[0-2])(-(0[1-9]|[12][0-9]|3[01]))?)?:.+$`) | ||
|
|
||
| // validateTagURI checks if the given string is a valid tag URI according to RFC 4151 | ||
| func validateTagURI(uri string) error { | ||
| if !tagURIPattern.MatchString(uri) { | ||
| return fmt.Errorf("invalid tag URI format: %q (expected format: tag:authority,date:specific)", uri) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| var ( | ||
| // PSA Token Profile ID using tag URI scheme | ||
| TokenProfileID *eat.Profile | ||
|
|
||
| // PSA Platform Endorsements Profile ID using tag URI scheme | ||
| EndorsementsProfileID *eat.Profile | ||
| ) | ||
|
|
||
| func init() { | ||
| var err error | ||
|
|
||
| // Validate and create Token Profile | ||
| if err = validateTagURI("tag:trustedcomputinggroup.org,2025:psa-token"); err != nil { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As with CCA, this check is pointless for a static string. |
||
| panic(err) | ||
| } | ||
| TokenProfileID, err = eat.NewProfile("tag:trustedcomputinggroup.org,2025:psa-token") | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| // Validate and create Endorsements Profile | ||
| if err = validateTagURI("tag:trustedcomputinggroup.org,2025:psa-endorsements"); err != nil { | ||
| panic(err) | ||
| } | ||
| EndorsementsProfileID, err = eat.NewProfile("tag:trustedcomputinggroup.org,2025:psa-endorsements") | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the prupose of this check? You're validating a static string (ditto for all
validateTagURI()calls bellow -- this function can probably be removed).