-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yogesh Deshpande <[email protected]>
- Loading branch information
1 parent
fea2ab2
commit e425713
Showing
6 changed files
with
232 additions
and
50 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,56 @@ | ||
// Copyright 2021-2023 Contributors to the Veraison project. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package cca_realm | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"github.com/veraison/ear" | ||
"github.com/veraison/services/handler" | ||
"github.com/veraison/services/proto" | ||
) | ||
|
||
func Test_SynthKeysFromRefValue_ok(t *testing.T) { | ||
endorsementsBytes, err := os.ReadFile("test/ref-val-endorsement.json") | ||
require.NoError(t, err) | ||
|
||
var endors handler.Endorsement | ||
err = json.Unmarshal(endorsementsBytes, &endors) | ||
require.NoError(t, err) | ||
expectedKey := "CCA_REALM://1/QoS1aUymwNLPR4mguVrIAlyBjeUjBDZL580pgbLS7caFsyInfsJYGZYkE9jJssH1" | ||
|
||
scheme := &EvidenceHandler{} | ||
key_list, err := scheme.SynthKeysFromRefValue("1", &endors) | ||
require.NoError(t, err) | ||
assert.Equal(t, expectedKey, key_list[0]) | ||
} | ||
|
||
func Test_AppraiseEvidence_ok(t *testing.T) { // nolint: dupl | ||
extractedBytes, err := os.ReadFile("test/cca-claims.json") | ||
require.NoError(t, err) | ||
|
||
var ec proto.EvidenceContext | ||
err = json.Unmarshal(extractedBytes, &ec) | ||
require.NoError(t, err) | ||
|
||
var endorsemementsArray []string | ||
endorsementsBytes, err := os.ReadFile("test/ref-val-endorsements.json") | ||
require.NoError(t, err) | ||
err = json.Unmarshal(endorsementsBytes, &endorsemementsArray) | ||
require.NoError(t, err) | ||
|
||
scheme := &EvidenceHandler{} | ||
|
||
result, err := scheme.AppraiseEvidence(&ec, endorsemementsArray) | ||
require.NoError(t, err) | ||
|
||
attestation := result.Submods["CCA_REALM"] | ||
|
||
assert.Equal(t, ear.TrustTierAffirming, *attestation.Status) | ||
assert.Equal(t, attestation.TrustVector.Executables, ear.ApprovedRuntimeClaim) | ||
} |
This file contains 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,59 @@ | ||
{ | ||
"evidence": { | ||
"platform": { | ||
"cca-platform-profile": "http://arm.com/CCA-SSD/1.0.0", | ||
"cca-platform-challenge": "AQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyA=", | ||
"cca-platform-implementation-id": "AQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyA=", | ||
"cca-platform-instance-id": "AQICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC", | ||
"cca-platform-config":"AQID", | ||
"cca-platform-lifecycle": 12288, | ||
"cca-platform-sw-components": [ | ||
{ | ||
"measurement-description": "TF-M_SHA256MemPreXIP", | ||
"measurement-type": "BL", | ||
"measurement-value": "BwYFBAMCAQAPDg0MCwoJCBcWFRQTEhEQHx4dHBsaGRg=", | ||
"signer-id": "BwYFBAMCAQAPDg0MCwoJCBcWFRQTEhEQHx4dHBsaGRg=", | ||
"version": "3.4.2" | ||
}, | ||
{ | ||
"measurement-type": "M1", | ||
"measurement-value": "CwYFBAMCAQAPDg0MCwoJCBcWFRQTEhEQHx4dHBsaGRg=", | ||
"signer-id": "BwYFBAMCAQAPDg0MCwoJCBcWFRQTEhEQHx4dHBsaGRg=", | ||
"version": "1.2.0" | ||
}, | ||
{ | ||
"measurement-type": "M2", | ||
"measurement-value": "DwYFBAMCAQAPDg0MCwoJCBcWFRQTEhEQHx4dHBsaGRg=", | ||
"signer-id": "BwYFBAMCAQAPDg0MCwoJCBcWFRQTEhEQHx4dHBsaGRg=", | ||
"version": "1.2.3" | ||
}, | ||
{ | ||
"measurement-type": "M3", | ||
"measurement-value": "EwYFBAMCAQAPDg0MCwoJCBcWFRQTEhEQHx4dHBsaGRg=", | ||
"signer-id": "BwYFBAMCAQAPDg0MCwoJCBcWFRQTEhEQHx4dHBsaGRg=", | ||
"version": "1.0.0" | ||
} | ||
], | ||
"cca-platform-service-indicator" : "https://veraison.example/v1/challenge-response", | ||
"cca-platform-hash-algo-id": "sha-256" | ||
}, | ||
"realm": { | ||
"cca-realm-challenge": "byTWuWNaLIu/WOkIuU4Ewb+zroDN6+gyQkV4SZ/jF2Hn9eHYvOASGET1Sr36UobaiPU6ZXsVM1yTlrQyklS8XA==", | ||
"cca-realm-personalization-value": "QURBREFEQURBREFEQURBREFEQURBREFEQURBREFEQURBREFEQURBREFEQURBREFEQURBREFEQURBREFEQURBRA==", | ||
"cca-realm-initial-measurement": "QoS1aUymwNLPR4mguVrIAlyBjeUjBDZL580pgbLS7caFsyInfsJYGZYkE9jJssH1", | ||
"cca-realm-extensible-measurements": [ | ||
"IQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4", | ||
"QQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4", | ||
"JQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4", | ||
"MQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" | ||
], | ||
"cca-realm-hash-algo-id": "sha-256", | ||
"cca-realm-public-key": "BIL70TKptcOWh5+7FTQNkFCXjlXHnVJ5oroOlYVPN+IM0vZPO3K1cLvXc+7iznaEJe31Re2+if+v4OlrvUbicPIHlsRIuY2vRqdk0nRC5ubthPjOyBfm7ManHTo959Z+zQ==", | ||
"cca-realm-public-key-hash-algo-id": "sha-512" | ||
} | ||
}, | ||
"reference-id": "CCA_SSD_PLATFORM://1/BwYFBAMCAQAPDg0MCwoJCBcWFRQTEhEQHx4dHBsaGRg=/AQcGBQQDAgEADw4NDAsKCQgXFhUUExIREB8eHRwbGhkY", | ||
"trust-anchor-id": "CCA_SSD_PLATFORM://1/BwYFBAMCAQAPDg0MCwoJCBcWFRQTEhEQHx4dHBsaGRg=/", | ||
"tenant-id": "1" | ||
} | ||
|
This file contains 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,19 @@ | ||
{ | ||
"scheme": "CCA_REALM", | ||
"type": "reference value", | ||
"subType": "", | ||
"attributes": { | ||
"cca-realm.alg-id": "sha-384", | ||
"cca-realm.id": "cd1f0e55-26f9-460d-b9d8-f7fde171787c", | ||
"cca-realm.measurement-array": [ | ||
"QoS1aUymwNLPR4mguVrIAlyBjeUjBDZL580pgbLS7caFsyInfsJYGZYkE9jJssH1", | ||
"IQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4", | ||
"QQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4", | ||
"JQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4", | ||
"MQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" | ||
], | ||
"cca-realm.model": "", | ||
"cca-realm.vendor": "Workload Client Ltd" | ||
} | ||
} | ||
|
This file contains 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,3 @@ | ||
[ | ||
"{ \"scheme\": \"CCA_REALM\", \"type\": \"reference value\",\"subType\": \"\", \"attributes\": { \"cca-realm.alg-id\": \"sha-384\",\"cca-realm.id\": \"cd1f0e55-26f9-460d-b9d8-f7fde171787c\", \"cca-realm.measurement-array\": [\"QoS1aUymwNLPR4mguVrIAlyBjeUjBDZL580pgbLS7caFsyInfsJYGZYkE9jJssH1\",\"IQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4\",\"QQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4\",\"JQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4\",\"MQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4\"],\"cca-realm.model\": \"\", \"cca-realm.vendor\": \"Workload Client Ltd\"}}" | ||
] |
Binary file not shown.