Skip to content

Commit

Permalink
namespace fix: veraison extensions go under ear. (#12)
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Fossati <[email protected]>

Signed-off-by: Thomas Fossati <[email protected]>
  • Loading branch information
thomas-fossati authored Oct 24, 2022
1 parent adc7908 commit 50cd251
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions ar4si.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ func (o AttestationResult) validate() error {
// Extensions contains any proprietary claims that can be optionally attached to the
// AttestationResult. For now only veraison-specific extensions are supported.
type Extensions struct {
VeraisonProcessedEvidence *map[string]interface{} `json:"veraison.processed-evidence,omitempty"`
VeraisonVerifierAddedClaims *map[string]interface{} `json:"veraison.verifier-added-claims,omitempty"`
VeraisonProcessedEvidence *map[string]interface{} `json:"ear.veraison.processed-evidence,omitempty"`
VeraisonVerifierAddedClaims *map[string]interface{} `json:"ear.veraison.verifier-added-claims,omitempty"`
}

// Verify cryptographically verifies the JWT data using the supplied key and
Expand Down
7 changes: 5 additions & 2 deletions ar4si_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package ar4si

import (
"fmt"
"testing"

"github.com/lestrrat-go/jwx/v2/jwa"
Expand Down Expand Up @@ -233,9 +234,9 @@ func TestFromJSON_fail(t *testing.T) {
func TestVerify_pass(t *testing.T) {
tvs := []string{
// ok
`eyJhbGciOiJFUzI1NiJ9.eyJlYXIuc3RhdHVzIjoiYWZmaXJtaW5nIiwiZWF0X3Byb2ZpbGUiOiJ0YWc6Z2l0aHViLmNvbS92ZXJhaXNvbi9hcjRzaSwyMDIyLTEwLTE3IiwiaWF0IjoxNjY2MDkxMzczLCJlYXIuYXBwcmFpc2FsLXBvbGljeS1pZCI6Imh0dHBzOi8vdmVyYWlzb24uZXhhbXBsZS9wb2xpY3kvMS82MGEwMDY4ZCIsInZlcmFpc29uLnByb2Nlc3NlZC1ldmlkZW5jZSI6eyJrMSI6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1jbGFpbXMiOnsiYmFyIjoiYmF6IiwiZm9vIjoiYmFyIn19.vo2KoisD9Bf18z7oymoS0Ty2ekurZiGti62-jn10jSMNfvGZQBjr9mFe1AroHzpjLBSzYfvXk6xlKf0domS3yQ.trailing-rubbish-is-ignored`,
`eyJhbGciOiJFUzI1NiJ9.eyJlYXIuc3RhdHVzIjoiYWZmaXJtaW5nIiwiZWF0X3Byb2ZpbGUiOiJ0YWc6Z2l0aHViLmNvbS92ZXJhaXNvbi9hcjRzaSwyMDIyLTEwLTE3IiwiaWF0IjoxNjY2MDkxMzczLCJlYXIuYXBwcmFpc2FsLXBvbGljeS1pZCI6Imh0dHBzOi8vdmVyYWlzb24uZXhhbXBsZS9wb2xpY3kvMS82MGEwMDY4ZCIsImVhci52ZXJhaXNvbi5wcm9jZXNzZWQtZXZpZGVuY2UiOnsiazEiOiJ2MSIsImsyIjoidjIifSwiZWFyLnZlcmFpc29uLnZlcmlmaWVyLWFkZGVkLWNsYWltcyI6eyJiYXIiOiJiYXoiLCJmb28iOiJiYXIifX0.horFZfZW49Sm9-tNU1A-W_qp9275B55idoDIe8zhHXqKizjodtXQh8FRU9B-TplM37lk38MomNvt1z3d8QaDjg.trailing-rubbish-is-ignored`,
}

k, err := jwk.ParseKey([]byte(testECDSAPublicKey))
Expand Down Expand Up @@ -306,6 +307,8 @@ func TestRoundTrip_pass(t *testing.T) {
token, err := testAttestationResultsWithVeraisonExtns.Sign(jwa.ES256, sigK)
assert.NoError(t, err)

fmt.Println(string(token))

vfyK, err := jwk.ParseKey([]byte(testECDSAPublicKey))
require.NoError(t, err)

Expand Down
6 changes: 3 additions & 3 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ func Example_encode_veraison_extensions() {
fmt.Println(string(j))

// Output:
// {"ear.status":"affirming","eat_profile":"tag:github.com/veraison/ar4si,2022-10-17","iat":1666091373,"ear.appraisal-policy-id":"https://veraison.example/policy/1/60a0068d","veraison.processed-evidence":{"k1":"v1","k2":"v2"},"veraison.verifier-added-claims":{"bar":"baz","foo":"bar"}}
// {"ear.status":"affirming","eat_profile":"tag:github.com/veraison/ar4si,2022-10-17","iat":1666091373,"ear.appraisal-policy-id":"https://veraison.example/policy/1/60a0068d","ear.veraison.processed-evidence":{"k1":"v1","k2":"v2"},"ear.veraison.verifier-added-claims":{"bar":"baz","foo":"bar"}}
}

func Example_decode_veraison_extensions() {
j := `{
"ear.status": "affirming",
"iat":1666091373,
"ear.appraisal-policy-id": "https://veraison.example/policy/1/60a0068d",
"veraison.processed-evidence": {
"ear.veraison.processed-evidence": {
"k1": "v1",
"k2": "v2"
},
"veraison.verifier-added-claims": {
"ear.veraison.verifier-added-claims": {
"bar": "baz",
"foo": "bar"
},
Expand Down

0 comments on commit 50cd251

Please sign in to comment.