Skip to content

Commit

Permalink
Merge pull request #41 from veraison/impl-fix
Browse files Browse the repository at this point in the history
Introduce API to get ImplementationID from PSA Evidence
  • Loading branch information
yogeshbdeshpande authored Oct 25, 2022
2 parents b92196b + 6391f10 commit 3c0bbd2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions evidence.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ func (e *Evidence) GetInstanceID() *[]byte {
return &instID
}

// GetImplementationID returns the ImplementationID claim from the
// PSA token or a nil pointer if no suitable ImplementationID could
// be located.
func (e *Evidence) GetImplementationID() *[]byte {
implID, err := e.Claims.GetImplID()
if err != nil {
return nil
}
return &implID
}

// FromCOSE extracts the PSA claims wrapped in the supplied CWT. As per spec,
// the only acceptable security envelope is COSE_Sign1.
func (e *Evidence) FromCOSE(cwt []byte) error {
Expand Down
13 changes: 13 additions & 0 deletions evidence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,19 @@ func TestEvidence_GetInstanceID_psa_profile_2_ok(t *testing.T) {
assert.Equal(t, expected, actual)
}

func TestEvidence_GetImplementationID_psa_profile_2_ok(t *testing.T) {
tv := mustBuildValidP2Claims(t, false)

evidence := Evidence{}
err := evidence.SetClaims(tv)
require.NoError(t, err)

expected := &testImplementationID

actual := evidence.GetImplementationID()
assert.Equal(t, expected, actual)
}

func TestEvidence_Verify_no_message(t *testing.T) {
evidence := Evidence{}
var pk crypto.PublicKey
Expand Down

0 comments on commit 3c0bbd2

Please sign in to comment.