From 37b188266ead24b2ce3d336148b43e6a31d89a89 Mon Sep 17 00:00:00 2001 From: Yogesh Deshpande Date: Wed, 29 May 2024 17:27:26 +0100 Subject: [PATCH] Add Realm Endorsement Tests Signed-off-by: Yogesh Deshpande --- scheme/cca/endorsement_handler_test.go | 50 ++++++- scheme/cca/test/corim/build-test-vectors.sh | 43 ++++++ scheme/cca/test/corim/comidCcaRealm.json | 79 +++++++++++ .../test/corim/comidCcaRealmInvalidClass.json | 79 +++++++++++ .../corim/comidCcaRealmInvalidInstance.json | 75 ++++++++++ .../cca/test/corim/comidCcaRealmNoClass.json | 68 +++++++++ .../test/corim/comidCcaRealmNoInstance.json | 71 ++++++++++ scheme/cca/test/corim/corimCcaRealm.json | 19 +++ scheme/cca/test_vectors.go | 129 ++++++++++++++++++ scheme/common/arm/cca_realm_attributes.go | 15 +- scheme/common/arm/realm_classattributes.go | 6 +- 11 files changed, 622 insertions(+), 12 deletions(-) create mode 100755 scheme/cca/test/corim/build-test-vectors.sh create mode 100644 scheme/cca/test/corim/comidCcaRealm.json create mode 100644 scheme/cca/test/corim/comidCcaRealmInvalidClass.json create mode 100644 scheme/cca/test/corim/comidCcaRealmInvalidInstance.json create mode 100644 scheme/cca/test/corim/comidCcaRealmNoClass.json create mode 100644 scheme/cca/test/corim/comidCcaRealmNoInstance.json create mode 100644 scheme/cca/test/corim/corimCcaRealm.json diff --git a/scheme/cca/endorsement_handler_test.go b/scheme/cca/endorsement_handler_test.go index 1091fef5..43d51b0f 100644 --- a/scheme/cca/endorsement_handler_test.go +++ b/scheme/cca/endorsement_handler_test.go @@ -65,7 +65,7 @@ func TestDecoder_Decode_invalid_data(t *testing.T) { assert.EqualError(t, err, expectedErr) } -func TestDecoder_Decode_CcaRefVal_OK(t *testing.T) { +func TestDecoder_Decode_CcaSsdRefVal_OK(t *testing.T) { tvs := []string{ unsignedCorimComidCcaRefValOne, unsignedCorimComidCcaRefValFour, @@ -80,7 +80,7 @@ func TestDecoder_Decode_CcaRefVal_OK(t *testing.T) { } } -func TestDecoder_Decode_CCaRefVal_NOK(t *testing.T) { +func TestDecoder_Decode_CCaSsdRefVal_NOK(t *testing.T) { tvs := []struct { desc string input string @@ -105,3 +105,49 @@ func TestDecoder_Decode_CCaRefVal_NOK(t *testing.T) { assert.EqualError(t, err, tv.expectedErr) } } + +func TestDecoder_DecodeCcaRealm_OK(t *testing.T) { + tvs := []string{ + unsignedCorimcomidCcaRealm, + unsignedCorimcomidCcaRealmNoClass, + } + + d := &EndorsementHandler{} + + for _, tv := range tvs { + data := comid.MustHexDecode(t, tv) + _, err := d.Decode(data) + assert.NoError(t, err) + } +} + +func TestDecoder_DecodeCcaRealm_negative_tests(t *testing.T) { + tvs := []struct { + desc string + input string + expectedErr string + }{ + { + desc: "no realm instance identity in corim", + input: unsignedCorimcomidCcaRealmNoInstance, + expectedErr: "bad software component in CoMID at index 0: could not extract Realm instance attributes: expecting instance in environment", + }, + { + desc: "invalid instance identity in corim", + input: unsignedCorimcomidCcaRealmInvalidInstance, + expectedErr: "bad software component in CoMID at index 0: could not extract Realm instance attributes: expecting instance as bytes for CCA Realm", + }, + { + desc: "invalid class identity in corim", + input: unsignedCorimcomidCcaRealmInvalidClass, + expectedErr: "bad software component in CoMID at index 0: could not extract Realm class attributes: could not extract uu-id from class-id: class-id type is: *comid.TaggedImplID", + }, + } + + for _, tv := range tvs { + data := comid.MustHexDecode(t, tv.input) + d := &EndorsementHandler{} + _, err := d.Decode(data) + assert.EqualError(t, err, tv.expectedErr) + } +} diff --git a/scheme/cca/test/corim/build-test-vectors.sh b/scheme/cca/test/corim/build-test-vectors.sh new file mode 100755 index 00000000..4dac74a3 --- /dev/null +++ b/scheme/cca/test/corim/build-test-vectors.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# Copyright 2022-2024 Contributors to the Veraison project. +# SPDX-License-Identifier: Apache-2.0 + +set -eu +set -o pipefail + +# function generate_go_test_vector constructs CBOR test vector using +# supplied comid and corim json template and saves them in a file +# $1 file name for comid json template, example one of COMID_TEMPLATES +# $2 file name for corim json template, example CORIM_TEMPLATE +# $3 a qualifier for each cbor test vector name +# $4 name of the file where the generated CBOR test vectors are aggregated +generate_go_test_vector () { + echo "generating test vector using $1 $2" + cocli comid create -t $1.json + cocli corim create -m $1.cbor -t $2 -o corim$1.cbor + echo "// automatically generated from:" >> $4 + echo "// $1.json and $2" >> $4 + echo "var $3$1 = "'`' >> $4 + cat corim$1.cbor | xxd -p >> $4 + echo '`' >> $4 +} + +CORIM_TEMPLATE="corimCcaRealm.json" + +COMID_TEMPLATES= +COMID_TEMPLATES="${COMID_TEMPLATES} comidCcaRealm" +COMID_TEMPLATES="${COMID_TEMPLATES} comidCcaRealmNoClass" +COMID_TEMPLATES="${COMID_TEMPLATES} comidCcaRealmNoInstance" +COMID_TEMPLATES="${COMID_TEMPLATES} comidCcaRealmInvalidInstance" +COMID_TEMPLATES="${COMID_TEMPLATES} comidCcaRealmInvalidClass" + +TV_DOT_GO=${TV_DOT_GO?must be set in the environment.} + +printf "package cca\n\n" > ${TV_DOT_GO} + +for t in ${COMID_TEMPLATES} +do + generate_go_test_vector $t $CORIM_TEMPLATE "unsignedCorim" $TV_DOT_GO +done + +gofmt -w $TV_DOT_GO \ No newline at end of file diff --git a/scheme/cca/test/corim/comidCcaRealm.json b/scheme/cca/test/corim/comidCcaRealm.json new file mode 100644 index 00000000..115db6e0 --- /dev/null +++ b/scheme/cca/test/corim/comidCcaRealm.json @@ -0,0 +1,79 @@ +{ + "lang": "en-GB", + "tag-identity": { + "id": "43BBE37F-2E61-4B33-AED3-53CFF1428B16", + "version": 0 + }, + "entities": [ + { + "name": "Workload Client Ltd.", + "regid": "https://workloadclient.example", + "roles": [ + "tagCreator", + "creator", + "maintainer" + ] + } + ], + "triples": { + "reference-values": [ + { + "environment": { + "class": { + "id": { + "type": "uuid", + "value": "CD1F0E55-26F9-460D-B9D8-F7FDE171787C" + }, + "vendor": "Workload Client Ltd" + }, + "instance": { + "type": "bytes", + "value": "QoS1aUymwNLPR4mguVrIAlyBjeUjBDZL580pgbLS7caFsyInfsJYGZYkE9jJssH1" + } + }, + "measurements": [ + { + "value": { + "raw-value": { + "type": "bytes", + "value": "5Fty9cDAtXLbTY06t+l/No/3TmI0eoJN7LZ6hOUiTXXkW3L1wMC1cttNjTq36X82j/dOYjR6gk3stnqE5SJNdQ==" + }, + "integrity-registers": { + "rim": { + "key-type": "text", + "value": [ + "sha-384;QoS1aUymwNLPR4mguVrIAlyBjeUjBDZL580pgbLS7caFsyInfsJYGZYkE9jJssH1" + ] + }, + "rem0": { + "key-type": "text", + "value": [ + "sha-384;IQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" + ] + }, + "rem1": { + "key-type": "text", + "value": [ + "sha-384;JQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" + ] + }, + "rem2": { + "key-type": "text", + "value": [ + "sha-384;MQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" + ] + }, + "rem3": { + "key-type": "text", + "value": [ + "sha-384;NQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" + ] + } + } + } + } + ] + } + ] + } +} \ No newline at end of file diff --git a/scheme/cca/test/corim/comidCcaRealmInvalidClass.json b/scheme/cca/test/corim/comidCcaRealmInvalidClass.json new file mode 100644 index 00000000..6cb1696c --- /dev/null +++ b/scheme/cca/test/corim/comidCcaRealmInvalidClass.json @@ -0,0 +1,79 @@ +{ + "lang": "en-GB", + "tag-identity": { + "id": "43BBE37F-2E61-4B33-AED3-53CFF1428B16", + "version": 0 + }, + "entities": [ + { + "name": "Workload Client Ltd.", + "regid": "https://workloadclient.example", + "roles": [ + "tagCreator", + "creator", + "maintainer" + ] + } + ], + "triples": { + "reference-values": [ + { + "environment": { + "class": { + "id": { + "type": "psa.impl-id", + "value": "YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE=" + }, + "vendor": "ACME" + }, + "instance": { + "type": "bytes", + "value": "QoS1aUymwNLPR4mguVrIAlyBjeUjBDZL580pgbLS7caFsyInfsJYGZYkE9jJssH1" + } + }, + "measurements": [ + { + "value": { + "raw-value": { + "type": "bytes", + "value": "5Fty9cDAtXLbTY06t+l/No/3TmI0eoJN7LZ6hOUiTXXkW3L1wMC1cttNjTq36X82j/dOYjR6gk3stnqE5SJNdQ==" + }, + "integrity-registers": { + "rim": { + "key-type": "text", + "value": [ + "sha-384;QoS1aUymwNLPR4mguVrIAlyBjeUjBDZL580pgbLS7caFsyInfsJYGZYkE9jJssH1" + ] + }, + "rem0": { + "key-type": "text", + "value": [ + "sha-384;IQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" + ] + }, + "rem1": { + "key-type": "text", + "value": [ + "sha-384;JQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" + ] + }, + "rem2": { + "key-type": "text", + "value": [ + "sha-384;MQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" + ] + }, + "rem3": { + "key-type": "text", + "value": [ + "sha-384;NQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" + ] + } + } + } + } + ] + } + ] + } +} \ No newline at end of file diff --git a/scheme/cca/test/corim/comidCcaRealmInvalidInstance.json b/scheme/cca/test/corim/comidCcaRealmInvalidInstance.json new file mode 100644 index 00000000..f451e5be --- /dev/null +++ b/scheme/cca/test/corim/comidCcaRealmInvalidInstance.json @@ -0,0 +1,75 @@ +{ + "lang": "en-GB", + "tag-identity": { + "id": "43BBE37F-2E61-4B33-AED3-53CFF1428B16", + "version": 0 + }, + "entities": [ + { + "name": "Workload Client Ltd.", + "regid": "https://workloadclient.example", + "roles": [ + "tagCreator", + "creator", + "maintainer" + ] + } + ], + "triples": { + "reference-values": [ + { + "environment": { + "class": { + "id": { + "type": "uuid", + "value": "CD1F0E55-26F9-460D-B9D8-F7FDE171787C" + }, + "vendor": "Workload Client Ltd" + }, + "instance": { + "type": "ueid", + "value": "Ac7rrnuJJ6MiflMDz14PH3s0u1Qq1yUKwD+83jbsLxUI" + } + }, + "measurements": [ + { + "value": { + "integrity-registers": { + "rim": { + "key-type": "text", + "value": [ + "sha-384;QoS1aUymwNLPR4mguVrIAlyBjeUjBDZL580pgbLS7caFsyInfsJYGZYkE9jJssH1" + ] + }, + "rem0": { + "key-type": "text", + "value": [ + "sha-384;IQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" + ] + }, + "rem1": { + "key-type": "text", + "value": [ + "sha-384;JQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" + ] + }, + "rem2": { + "key-type": "text", + "value": [ + "sha-384;MQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" + ] + }, + "rem3": { + "key-type": "text", + "value": [ + "sha-384;NQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" + ] + } + } + } + } + ] + } + ] + } +} \ No newline at end of file diff --git a/scheme/cca/test/corim/comidCcaRealmNoClass.json b/scheme/cca/test/corim/comidCcaRealmNoClass.json new file mode 100644 index 00000000..9324d73e --- /dev/null +++ b/scheme/cca/test/corim/comidCcaRealmNoClass.json @@ -0,0 +1,68 @@ +{ + "lang": "en-GB", + "tag-identity": { + "id": "43BBE37F-2E61-4B33-AED3-53CFF1428B16", + "version": 0 + }, + "entities": [ + { + "name": "Workload Client Ltd.", + "regid": "https://workloadclient.example", + "roles": [ + "tagCreator", + "creator", + "maintainer" + ] + } + ], + "triples": { + "reference-values": [ + { + "environment": { + "instance": { + "type": "bytes", + "value": "QoS1aUymwNLPR4mguVrIAlyBjeUjBDZL580pgbLS7caFsyInfsJYGZYkE9jJssH1" + } + }, + "measurements": [ + { + "value": { + "integrity-registers": { + "rim": { + "key-type": "text", + "value": [ + "sha-384;QoS1aUymwNLPR4mguVrIAlyBjeUjBDZL580pgbLS7caFsyInfsJYGZYkE9jJssH1" + ] + }, + "rem0": { + "key-type": "text", + "value": [ + "sha-384;IQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" + ] + }, + "rem1": { + "key-type": "text", + "value": [ + "sha-384;JQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" + ] + }, + "rem2": { + "key-type": "text", + "value": [ + "sha-384;MQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" + ] + }, + "rem3": { + "key-type": "text", + "value": [ + "sha-384;NQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" + ] + } + } + } + } + ] + } + ] + } +} \ No newline at end of file diff --git a/scheme/cca/test/corim/comidCcaRealmNoInstance.json b/scheme/cca/test/corim/comidCcaRealmNoInstance.json new file mode 100644 index 00000000..0e32cc81 --- /dev/null +++ b/scheme/cca/test/corim/comidCcaRealmNoInstance.json @@ -0,0 +1,71 @@ +{ + "lang": "en-GB", + "tag-identity": { + "id": "43BBE37F-2E61-4B33-AED3-53CFF1428B16", + "version": 0 + }, + "entities": [ + { + "name": "Workload Client Ltd.", + "regid": "https://workloadclient.example", + "roles": [ + "tagCreator", + "creator", + "maintainer" + ] + } + ], + "triples": { + "reference-values": [ + { + "environment": { + "class": { + "id": { + "type": "uuid", + "value": "CD1F0E55-26F9-460D-B9D8-F7FDE171787C" + }, + "vendor": "Workload Client Ltd" + } + }, + "measurements": [ + { + "value": { + "integrity-registers": { + "rim": { + "key-type": "text", + "value": [ + "sha-384;QoS1aUymwNLPR4mguVrIAlyBjeUjBDZL580pgbLS7caFsyInfsJYGZYkE9jJssH1" + ] + }, + "rem0": { + "key-type": "text", + "value": [ + "sha-384;IQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" + ] + }, + "rem1": { + "key-type": "text", + "value": [ + "sha-384;JQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" + ] + }, + "rem2": { + "key-type": "text", + "value": [ + "sha-384;MQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" + ] + }, + "rem3": { + "key-type": "text", + "value": [ + "sha-384;NQe752H8pS2VE2oTVNt6TdV7Gya+DT2nHZ6yOYazS6YVq/ZRTPNeWp6lWgMtBop4" + ] + } + } + } + } + ] + } + ] + } +} \ No newline at end of file diff --git a/scheme/cca/test/corim/corimCcaRealm.json b/scheme/cca/test/corim/corimCcaRealm.json new file mode 100644 index 00000000..8dfd86d0 --- /dev/null +++ b/scheme/cca/test/corim/corimCcaRealm.json @@ -0,0 +1,19 @@ +{ + "corim-id": "5c57e8f4-46cd-421b-91c9-08cf93e13cfc", + "profiles": [ + "http://arm.com/cca/realm/1" + ], + "validity": { + "not-before": "2021-12-31T00:00:00Z", + "not-after": "2025-12-31T00:00:00Z" + }, + "entities": [ + { + "name": "ACME Ltd.", + "regid": "acme.example", + "roles": [ + "manifestCreator" + ] + } + ] +} \ No newline at end of file diff --git a/scheme/cca/test_vectors.go b/scheme/cca/test_vectors.go index db6f363b..851de26a 100644 --- a/scheme/cca/test_vectors.go +++ b/scheme/cca/test_vectors.go @@ -91,3 +91,132 @@ c3f9bebb6bc24f32ffd5b67b387244c2c909da779a1478a200d9025a6961 0001c11a695467800581a3006941434d45204c74642e01d8206c61636d65 2e6578616d706c65028101 ` + +// automatically generated from: +// comidCcaRealm.json and corimCcaRealm.json +var unsignedCorimcomidCcaRealm = ` +a500505c57e8f446cd421b91c908cf93e13cfc0181590234d901faa40065 +656e2d474201a1005043bbe37f2e614b33aed353cff1428b160281a30074 +576f726b6c6f616420436c69656e74204c74642e01d820781e6874747073 +3a2f2f776f726b6c6f6164636c69656e742e6578616d706c650283000102 +04a1008182a200a200d82550cd1f0e5526f9460db9d8f7fde171787c0173 +576f726b6c6f616420436c69656e74204c746401d9023058304284b5694c +a6c0d2cf4789a0b95ac8025c818de52304364be7cd2981b2d2edc685b322 +277ec25819962413d8c9b2c1f581a101a204d902305840e45b72f5c0c0b5 +72db4d8d3ab7e97f368ff74e62347a824decb67a84e5224d75e45b72f5c0 +c0b572db4d8d3ab7e97f368ff74e62347a824decb67a84e5224d750ea563 +72696d81820758304284b5694ca6c0d2cf4789a0b95ac8025c818de52304 +364be7cd2981b2d2edc685b322277ec25819962413d8c9b2c1f56472656d +3081820758302107bbe761fca52d95136a1354db7a4dd57b1b26be0d3da7 +1d9eb23986b34ba615abf6514cf35e5a9ea55a032d068a786472656d3181 +820758302507bbe761fca52d95136a1354db7a4dd57b1b26be0d3da71d9e +b23986b34ba615abf6514cf35e5a9ea55a032d068a786472656d32818207 +58303107bbe761fca52d95136a1354db7a4dd57b1b26be0d3da71d9eb239 +86b34ba615abf6514cf35e5a9ea55a032d068a786472656d338182075830 +3507bbe761fca52d95136a1354db7a4dd57b1b26be0d3da71d9eb23986b3 +4ba615abf6514cf35e5a9ea55a032d068a780381781a687474703a2f2f61 +726d2e636f6d2f6363612f7265616c6d2f3104a200c11a61ce480001c11a +695467800581a3006941434d45204c74642e01d8206c61636d652e657861 +6d706c65028101 +` + +// automatically generated from: +// comidCcaRealmNoClass.json and corimCcaRealm.json +var unsignedCorimcomidCcaRealmNoClass = ` +a500505c57e8f446cd421b91c908cf93e13cfc01815901c3d901faa40065 +656e2d474201a1005043bbe37f2e614b33aed353cff1428b160281a30074 +576f726b6c6f616420436c69656e74204c74642e01d820781e6874747073 +3a2f2f776f726b6c6f6164636c69656e742e6578616d706c650283000102 +04a1008182a101d9023058304284b5694ca6c0d2cf4789a0b95ac8025c81 +8de52304364be7cd2981b2d2edc685b322277ec25819962413d8c9b2c1f5 +81a101a10ea56372696d81820758304284b5694ca6c0d2cf4789a0b95ac8 +025c818de52304364be7cd2981b2d2edc685b322277ec25819962413d8c9 +b2c1f56472656d3081820758302107bbe761fca52d95136a1354db7a4dd5 +7b1b26be0d3da71d9eb23986b34ba615abf6514cf35e5a9ea55a032d068a +786472656d3181820758302507bbe761fca52d95136a1354db7a4dd57b1b +26be0d3da71d9eb23986b34ba615abf6514cf35e5a9ea55a032d068a7864 +72656d3281820758303107bbe761fca52d95136a1354db7a4dd57b1b26be +0d3da71d9eb23986b34ba615abf6514cf35e5a9ea55a032d068a78647265 +6d3381820758303507bbe761fca52d95136a1354db7a4dd57b1b26be0d3d +a71d9eb23986b34ba615abf6514cf35e5a9ea55a032d068a780381781a68 +7474703a2f2f61726d2e636f6d2f6363612f7265616c6d2f3104a200c11a +61ce480001c11a695467800581a3006941434d45204c74642e01d8206c61 +636d652e6578616d706c65028101 +` + +// automatically generated from: +// comidCcaRealmNoInstance.json and corimCcaRealm.json +var unsignedCorimcomidCcaRealmNoInstance = ` +a500505c57e8f446cd421b91c908cf93e13cfc01815901b8d901faa40065 +656e2d474201a1005043bbe37f2e614b33aed353cff1428b160281a30074 +576f726b6c6f616420436c69656e74204c74642e01d820781e6874747073 +3a2f2f776f726b6c6f6164636c69656e742e6578616d706c650283000102 +04a1008182a100a200d82550cd1f0e5526f9460db9d8f7fde171787c0173 +576f726b6c6f616420436c69656e74204c746481a101a10ea56372696d81 +820758304284b5694ca6c0d2cf4789a0b95ac8025c818de52304364be7cd +2981b2d2edc685b322277ec25819962413d8c9b2c1f56472656d30818207 +58302107bbe761fca52d95136a1354db7a4dd57b1b26be0d3da71d9eb239 +86b34ba615abf6514cf35e5a9ea55a032d068a786472656d318182075830 +2507bbe761fca52d95136a1354db7a4dd57b1b26be0d3da71d9eb23986b3 +4ba615abf6514cf35e5a9ea55a032d068a786472656d3281820758303107 +bbe761fca52d95136a1354db7a4dd57b1b26be0d3da71d9eb23986b34ba6 +15abf6514cf35e5a9ea55a032d068a786472656d3381820758303507bbe7 +61fca52d95136a1354db7a4dd57b1b26be0d3da71d9eb23986b34ba615ab +f6514cf35e5a9ea55a032d068a780381781a687474703a2f2f61726d2e63 +6f6d2f6363612f7265616c6d2f3104a200c11a61ce480001c11a69546780 +0581a3006941434d45204c74642e01d8206c61636d652e6578616d706c65 +028101 +` + +// automatically generated from: +// comidCcaRealmInvalidInstance.json and corimCcaRealm.json +var unsignedCorimcomidCcaRealmInvalidInstance = ` +a500505c57e8f446cd421b91c908cf93e13cfc01815901dfd901faa40065 +656e2d474201a1005043bbe37f2e614b33aed353cff1428b160281a30074 +576f726b6c6f616420436c69656e74204c74642e01d820781e6874747073 +3a2f2f776f726b6c6f6164636c69656e742e6578616d706c650283000102 +04a1008182a200a200d82550cd1f0e5526f9460db9d8f7fde171787c0173 +576f726b6c6f616420436c69656e74204c746401d90226582101ceebae7b +8927a3227e5303cf5e0f1f7b34bb542ad7250ac03fbcde36ec2f150881a1 +01a10ea56372696d81820758304284b5694ca6c0d2cf4789a0b95ac8025c +818de52304364be7cd2981b2d2edc685b322277ec25819962413d8c9b2c1 +f56472656d3081820758302107bbe761fca52d95136a1354db7a4dd57b1b +26be0d3da71d9eb23986b34ba615abf6514cf35e5a9ea55a032d068a7864 +72656d3181820758302507bbe761fca52d95136a1354db7a4dd57b1b26be +0d3da71d9eb23986b34ba615abf6514cf35e5a9ea55a032d068a78647265 +6d3281820758303107bbe761fca52d95136a1354db7a4dd57b1b26be0d3d +a71d9eb23986b34ba615abf6514cf35e5a9ea55a032d068a786472656d33 +81820758303507bbe761fca52d95136a1354db7a4dd57b1b26be0d3da71d +9eb23986b34ba615abf6514cf35e5a9ea55a032d068a780381781a687474 +703a2f2f61726d2e636f6d2f6363612f7265616c6d2f3104a200c11a61ce +480001c11a695467800581a3006941434d45204c74642e01d8206c61636d +652e6578616d706c65028101 +` + +// automatically generated from: +// comidCcaRealmInvalidClass.json and corimCcaRealm.json +var unsignedCorimcomidCcaRealmInvalidClass = ` +a500505c57e8f446cd421b91c908cf93e13cfc0181590237d901faa40065 +656e2d474201a1005043bbe37f2e614b33aed353cff1428b160281a30074 +576f726b6c6f616420436c69656e74204c74642e01d820781e6874747073 +3a2f2f776f726b6c6f6164636c69656e742e6578616d706c650283000102 +04a1008182a200a200d90258582061636d652d696d706c656d656e746174 +696f6e2d69642d303030303030303031016441434d4501d9023058304284 +b5694ca6c0d2cf4789a0b95ac8025c818de52304364be7cd2981b2d2edc6 +85b322277ec25819962413d8c9b2c1f581a101a204d902305840e45b72f5 +c0c0b572db4d8d3ab7e97f368ff74e62347a824decb67a84e5224d75e45b +72f5c0c0b572db4d8d3ab7e97f368ff74e62347a824decb67a84e5224d75 +0ea56372696d81820758304284b5694ca6c0d2cf4789a0b95ac8025c818d +e52304364be7cd2981b2d2edc685b322277ec25819962413d8c9b2c1f564 +72656d3081820758302107bbe761fca52d95136a1354db7a4dd57b1b26be +0d3da71d9eb23986b34ba615abf6514cf35e5a9ea55a032d068a78647265 +6d3181820758302507bbe761fca52d95136a1354db7a4dd57b1b26be0d3d +a71d9eb23986b34ba615abf6514cf35e5a9ea55a032d068a786472656d32 +81820758303107bbe761fca52d95136a1354db7a4dd57b1b26be0d3da71d +9eb23986b34ba615abf6514cf35e5a9ea55a032d068a786472656d338182 +0758303507bbe761fca52d95136a1354db7a4dd57b1b26be0d3da71d9eb2 +3986b34ba615abf6514cf35e5a9ea55a032d068a780381781a687474703a +2f2f61726d2e636f6d2f6363612f7265616c6d2f3104a200c11a61ce4800 +01c11a695467800581a3006941434d45204c74642e01d8206c61636d652e +6578616d706c65028101 +` diff --git a/scheme/common/arm/cca_realm_attributes.go b/scheme/common/arm/cca_realm_attributes.go index de9654a5..87278c71 100644 --- a/scheme/common/arm/cca_realm_attributes.go +++ b/scheme/common/arm/cca_realm_attributes.go @@ -58,15 +58,15 @@ func (o *RealmAttributes) extractRegisterIndexes(r *comid.IntegrityRegisters) er switch key { case "rim": o.HashAlgID = a - *o.Rim = d + o.Rim = &d case "rem0": - *o.Rem[0] = d + o.Rem[0] = &d case "rem1": - *o.Rem[1] = d + o.Rem[1] = &d case "rem2": - *o.Rem[2] = d + o.Rem[2] = &d case "rem3": - *o.Rem[3] = d + o.Rem[3] = &d default: return fmt.Errorf("unexpected register index: %s", key) } @@ -87,14 +87,15 @@ func (o *RealmAttributes) extractRealmPersonalizationValue(r *comid.RawValue) er log.Debug("realm personalization value not present") return nil } - *o.Rpv, err = r.GetBytes() + rpv, err := r.GetBytes() if err != nil { return err - } else if len(*o.Rpv) != 64 { + } else if len(rpv) != 64 { { return fmt.Errorf("invalid length %d, for realm personalization value", len(*o.Rpv)) } } + o.Rpv = &rpv return nil } diff --git a/scheme/common/arm/realm_classattributes.go b/scheme/common/arm/realm_classattributes.go index 5f45a960..c9509492 100644 --- a/scheme/common/arm/realm_classattributes.go +++ b/scheme/common/arm/realm_classattributes.go @@ -37,12 +37,12 @@ func (o *RealmClassAttributes) FromEnvironment(e comid.Environment) error { if err := UUID.Valid(); err != nil { return fmt.Errorf("no valid uu-id: %w", err) } - - *o.UUID = UUID.String() + uuid := UUID.String() + o.UUID = &uuid } if class.Vendor != nil { - *o.Vendor = *class.Vendor + o.Vendor = class.Vendor } else { return errors.New("class is neither UUID or Vendor Name") }