diff --git a/comid/comid_test.go b/comid/comid_test.go index a708b11..7aed60d 100644 --- a/comid/comid_test.go +++ b/comid/comid_test.go @@ -48,11 +48,11 @@ func Test_Comid_ToJSONPretty(t *testing.T) { Environment: Environment{ Instance: MustNewUUIDInstance(TestUUID), }, - Measurement: Measurement{ + Measurements: *NewMeasurements().Add(&Measurement{ Val: Mval{ RawValue: NewRawValue().SetBytes(MustHexDecode(t, "deadbeef")), }, - }, + }), }), } @@ -70,14 +70,16 @@ func Test_Comid_ToJSONPretty(t *testing.T) { "value": "31fb5abf-023e-4992-aa4e-95f9c1503bfa" } }, - "measurement": { - "value": { - "raw-value": { - "type": "bytes", - "value": "3q2+7w==" + "measurements": [ + { + "value": { + "raw-value": { + "type": "bytes", + "value": "3q2+7w==" + } } } - } + ] } ] } diff --git a/comid/example_cca_realm_refval_test.go b/comid/example_cca_realm_refval_test.go index fa17fb7..a8907f3 100644 --- a/comid/example_cca_realm_refval_test.go +++ b/comid/example_cca_realm_refval_test.go @@ -71,8 +71,21 @@ func extractRealmRefVal(rv ValueTriple) error { return fmt.Errorf("extracting realm instanceID: %w", err) } - if err := extractMeasurement(rv.Measurement); err != nil { - return fmt.Errorf("extracting measurement: %w", err) + measurements := rv.Measurements + if err := extractMeasurements(measurements); err != nil { + return fmt.Errorf("extracting measurements: %w", err) + } + return nil +} + +func extractMeasurements(m Measurements) error { + if len(m.Values) == 0 { + return fmt.Errorf("no measurements") + } + for i, meas := range m.Values { + if err := extractMeasurement(meas); err != nil { + return fmt.Errorf("extracting measurement at index %d: %w", i, err) + } } return nil diff --git a/comid/example_cca_refval_test.go b/comid/example_cca_refval_test.go index 1e6787b..7a551ba 100644 --- a/comid/example_cca_refval_test.go +++ b/comid/example_cca_refval_test.go @@ -20,25 +20,21 @@ func Example_cca_refval() { panic(err) } - // output: - //ImplementationID: 61636d652d696d706c656d656e746174696f6e2d69642d303030303030303031 - //SignerID: acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b - //Label: BL - //Version: 2.1.0 - //Digest: 87428fc522803d31065e7bce3cf03fe475096631e5e07bbd7a0fde60c4cf25c7 - //ImplementationID: 61636d652d696d706c656d656e746174696f6e2d69642d303030303030303031 - //SignerID: acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b - //Label: PRoT - //Version: 1.3.5 - //Digest: 0263829989b6fd954f72baaf2fc64bc2e2f01d692d4de72986ea808f6e99813f - //ImplementationID: 61636d652d696d706c656d656e746174696f6e2d69642d303030303030303031 - //SignerID: acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b - //Label: ARoT - //Version: 0.1.4 - //Digest: a3a5e715f0cc574a73c3f9bebb6bc24f32ffd5b67b387244c2c909da779a1478 - //ImplementationID: 61636d652d696d706c656d656e746174696f6e2d69642d303030303030303031 - //Label: a non-empty (unique) label - //Raw value: 72617776616c75650a72617776616c75650a + // ImplementationID: 61636d652d696d706c656d656e746174696f6e2d69642d303030303030303031 + // SignerID: acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b + // Label: BL + // Version: 2.1.0 + // Digest: 87428fc522803d31065e7bce3cf03fe475096631e5e07bbd7a0fde60c4cf25c7 + // SignerID: acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b + // Label: PRoT + // Version: 1.3.5 + // Digest: 0263829989b6fd954f72baaf2fc64bc2e2f01d692d4de72986ea808f6e99813f + // SignerID: acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b + // Label: ARoT + // Version: 0.1.4 + // Digest: a3a5e715f0cc574a73c3f9bebb6bc24f32ffd5b67b387244c2c909da779a1478 + // Label: a non-empty (unique) label + // Raw value: 72617776616c75650a72617776616c75650a } func extractCcaRefVals(c *Comid) error { @@ -57,33 +53,33 @@ func extractCcaRefVals(c *Comid) error { func extractCCARefVal(rv ValueTriple) error { class := rv.Environment.Class - m := rv.Measurement if err := extractImplementationID(class); err != nil { return fmt.Errorf("extracting impl-id: %w", err) } - if m.Key == nil { - return fmt.Errorf("missing mKey") - } - if !m.Key.IsSet() { - return fmt.Errorf("mKey not set") - } - - switch t := m.Key.Value.(type) { - case *TaggedPSARefValID: - if err := extractSwMeasurement(m); err != nil { - return fmt.Errorf("extracting measurement: %w", err) + for i, m := range rv.Measurements.Values { + if m.Key == nil { + return fmt.Errorf("missing mKey at index %d", i) } - case *TaggedCCAPlatformConfigID: - if err := extractCCARefValID(m.Key); err != nil { - return fmt.Errorf("extracting cca-refval-id: %w", err) + if !m.Key.IsSet() { + return fmt.Errorf("mKey not set at index %d", i) } - if err := extractRawValue(m.Val.RawValue); err != nil { - return fmt.Errorf("extracting raw vlue: %w", err) + switch t := m.Key.Value.(type) { + case *TaggedPSARefValID: + if err := extractSwMeasurement(m); err != nil { + return fmt.Errorf("extracting measurement at index %d: %w", i, err) + } + case *TaggedCCAPlatformConfigID: + if err := extractCCARefValID(m.Key); err != nil { + return fmt.Errorf("extracting cca-refval-id: %w", err) + } + if err := extractRawValue(m.Val.RawValue); err != nil { + return fmt.Errorf("extracting raw vlue: %w", err) + } + default: + return fmt.Errorf("unexpected Mkey type: %T", t) } - default: - return fmt.Errorf("unexpected Mkey type: %T", t) } return nil diff --git a/comid/example_psa_refval_test.go b/comid/example_psa_refval_test.go index 1d7c7bb..3cf4569 100644 --- a/comid/example_psa_refval_test.go +++ b/comid/example_psa_refval_test.go @@ -20,22 +20,20 @@ func Example_psa_refval() { panic(err) } - // output: - //ImplementationID: 61636d652d696d706c656d656e746174696f6e2d69642d303030303030303031 - //SignerID: acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b - //Label: BL - //Version: 2.1.0 - //Digest: 87428fc522803d31065e7bce3cf03fe475096631e5e07bbd7a0fde60c4cf25c7 - //ImplementationID: 61636d652d696d706c656d656e746174696f6e2d69642d303030303030303031 - //SignerID: acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b - //Label: PRoT - //Version: 1.3.5 - //Digest: 0263829989b6fd954f72baaf2fc64bc2e2f01d692d4de72986ea808f6e99813f - //ImplementationID: 61636d652d696d706c656d656e746174696f6e2d69642d303030303030303031 - //SignerID: acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b - //Label: ARoT - //Version: 0.1.4 - //Digest: a3a5e715f0cc574a73c3f9bebb6bc24f32ffd5b67b387244c2c909da779a1478 + // ImplementationID: 61636d652d696d706c656d656e746174696f6e2d69642d303030303030303031 + // SignerID: acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b + // Label: BL + // Version: 2.1.0 + // Digest: 87428fc522803d31065e7bce3cf03fe475096631e5e07bbd7a0fde60c4cf25c7 + // SignerID: acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b + // Label: PRoT + // Version: 1.3.5 + // Digest: 0263829989b6fd954f72baaf2fc64bc2e2f01d692d4de72986ea808f6e99813f + // SignerID: acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b + // Label: ARoT + // Version: 0.1.4 + // Digest: a3a5e715f0cc574a73c3f9bebb6bc24f32ffd5b67b387244c2c909da779a1478 + } func extractRefVals(c *Comid) error { @@ -59,13 +57,26 @@ func extractPSARefVal(rv ValueTriple) error { return fmt.Errorf("extracting impl-id: %w", err) } - if err := extractSwMeasurement(rv.Measurement); err != nil { + measurements := rv.Measurements + if err := extractSwMeasurements(measurements); err != nil { return fmt.Errorf("extracting measurements: %w", err) } return nil } +func extractSwMeasurements(m Measurements) error { + if len(m.Values) == 0 { + return fmt.Errorf("no measurements") + } + for i, m := range m.Values { + if err := extractSwMeasurement(m); err != nil { + return fmt.Errorf("extracting measurement at index %d: %w", i, err) + } + } + return nil +} + func extractSwMeasurement(m Measurement) error { if err := extractPSARefValID(m.Key); err != nil { return fmt.Errorf("extracting PSA refval id: %w", err) diff --git a/comid/example_test.go b/comid/example_test.go index ce9a36a..e807be6 100644 --- a/comid/example_test.go +++ b/comid/example_test.go @@ -6,6 +6,7 @@ package comid import ( _ "embed" "fmt" + "testing" "github.com/google/uuid" "github.com/veraison/swid" @@ -30,18 +31,21 @@ func Example_encode() { Instance: MustNewUEIDInstance(TestUEID), Group: MustNewUUIDGroup(TestUUID), }, - Measurement: *MustNewUUIDMeasurement(TestUUID). - SetRawValueBytes([]byte{0x01, 0x02, 0x03, 0x04}, []byte{0xff, 0xff, 0xff, 0xff}). - SetSVN(2). - AddDigest(swid.Sha256_32, []byte{0xab, 0xcd, 0xef, 0x00}). - AddDigest(swid.Sha256_32, []byte{0xff, 0xff, 0xff, 0xff}). - SetFlagsTrue(FlagIsDebug). - SetFlagsFalse(FlagIsSecure). - SetSerialNumber("C02X70VHJHD5"). - SetUEID(TestUEID). - SetUUID(TestUUID). - SetMACaddr(MACaddr(TestMACaddr)). - SetIPaddr(TestIPaddr), + Measurements: *NewMeasurements(). + Add( + MustNewUUIDMeasurement(TestUUID). + SetRawValueBytes([]byte{0x01, 0x02, 0x03, 0x04}, []byte{0xff, 0xff, 0xff, 0xff}). + SetSVN(2). + AddDigest(swid.Sha256_32, []byte{0xab, 0xcd, 0xef, 0x00}). + AddDigest(swid.Sha256_32, []byte{0xff, 0xff, 0xff, 0xff}). + SetFlagsTrue(FlagIsDebug). + SetFlagsFalse(FlagIsSecure). + SetSerialNumber("C02X70VHJHD5"). + SetUEID(TestUEID). + SetUUID(TestUUID). + SetMACaddr(MACaddr(TestMACaddr)). + SetIPaddr(TestIPaddr), + ), }, ). AddEndorsedValue( @@ -55,18 +59,21 @@ func Example_encode() { Instance: MustNewUEIDInstance(TestUEID), Group: MustNewUUIDGroup(TestUUID), }, - Measurement: *MustNewUUIDMeasurement(TestUUID). - SetRawValueBytes([]byte{0x01, 0x02, 0x03, 0x04}, []byte{0xff, 0xff, 0xff, 0xff}). - SetMinSVN(2). - AddDigest(swid.Sha256_32, []byte{0xab, 0xcd, 0xef, 0x00}). - AddDigest(swid.Sha256_32, []byte{0xff, 0xff, 0xff, 0xff}). - SetFlagsTrue(FlagIsDebug). - SetFlagsFalse(FlagIsSecure, FlagIsConfigured). - SetSerialNumber("C02X70VHJHD5"). - SetUEID(TestUEID). - SetUUID(TestUUID). - SetMACaddr(MACaddr(TestMACaddr)). - SetIPaddr(TestIPaddr), + Measurements: *NewMeasurements(). + Add( + MustNewUUIDMeasurement(TestUUID). + SetRawValueBytes([]byte{0x01, 0x02, 0x03, 0x04}, []byte{0xff, 0xff, 0xff, 0xff}). + SetMinSVN(2). + AddDigest(swid.Sha256_32, []byte{0xab, 0xcd, 0xef, 0x00}). + AddDigest(swid.Sha256_32, []byte{0xff, 0xff, 0xff, 0xff}). + SetFlagsTrue(FlagIsDebug). + SetFlagsFalse(FlagIsSecure, FlagIsConfigured). + SetSerialNumber("C02X70VHJHD5"). + SetUEID(TestUEID). + SetUUID(TestUUID). + SetMACaddr(MACaddr(TestMACaddr)). + SetIPaddr(TestIPaddr), + ), }, ). AddAttestVerifKey( @@ -102,8 +109,8 @@ func Example_encode() { } // Output: - //a50065656e2d474201a10078206d792d6e733a61636d652d726f616472756e6e65722d737570706c656d656e740282a3006941434d45204c74642e01d8207468747470733a2f2f61636d652e6578616d706c6502820100a20069454d4341204c74642e0281020382a200781a6d792d6e733a61636d652d726f616472756e6e65722d626173650100a20078196d792d6e733a61636d652d726f616472756e6e65722d6f6c64010104a4008182a300a500d86f445502c000016941434d45204c74642e026a526f616452756e6e65720300040101d902264702deadbeefdead02d8255031fb5abf023e4992aa4e95f9c1503bfaa200d8255031fb5abf023e4992aa4e95f9c1503bfa01aa01d90228020282820644abcdef00820644ffffffff03a201f403f504d9023044010203040544ffffffff064802005e1000000001075020010db8000000000000000000000068086c43303258373056484a484435094702deadbeefdead0a5031fb5abf023e4992aa4e95f9c1503bfa018182a300a500d8255031fb5abf023e4992aa4e95f9c1503bfa016941434d45204c74642e026a526f616452756e6e65720300040101d902264702deadbeefdead02d8255031fb5abf023e4992aa4e95f9c1503bfaa200d8255031fb5abf023e4992aa4e95f9c1503bfa01aa01d90229020282820644abcdef00820644ffffffff03a300f401f403f504d9023044010203040544ffffffff064802005e1000000001075020010db8000000000000000000000068086c43303258373056484a484435094702deadbeefdead0a5031fb5abf023e4992aa4e95f9c1503bfa028182a101d902264702deadbeefdead81d9022a78b12d2d2d2d2d424547494e205055424c4943204b45592d2d2d2d2d0a4d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a304441516344516741455731427671462b2f727938425761375a454d553178595948455138420a6c4c54344d46484f614f2b4943547449767245654570722f7366544150363648326843486462354845584b74524b6f6436514c634f4c504131513d3d0a2d2d2d2d2d454e44205055424c4943204b45592d2d2d2d2d038182a101d8255031fb5abf023e4992aa4e95f9c1503bfa81d9022a78b12d2d2d2d2d424547494e205055424c4943204b45592d2d2d2d2d0a4d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a304441516344516741455731427671462b2f727938425761375a454d553178595948455138420a6c4c54344d46484f614f2b4943547449767245654570722f7366544150363648326843486462354845584b74524b6f6436514c634f4c504131513d3d0a2d2d2d2d2d454e44205055424c4943204b45592d2d2d2d2d - //{"lang":"en-GB","tag-identity":{"id":"my-ns:acme-roadrunner-supplement"},"entities":[{"name":"ACME Ltd.","regid":"https://acme.example","roles":["creator","tagCreator"]},{"name":"EMCA Ltd.","roles":["maintainer"]}],"linked-tags":[{"target":"my-ns:acme-roadrunner-base","rel":"supplements"},{"target":"my-ns:acme-roadrunner-old","rel":"replaces"}],"triples":{"reference-values":[{"environment":{"class":{"id":{"type":"oid","value":"2.5.2.8192"},"vendor":"ACME Ltd.","model":"RoadRunner","layer":0,"index":1},"instance":{"type":"ueid","value":"At6tvu/erQ=="},"group":{"type":"uuid","value":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"}},"measurement":{"key":{"type":"uuid","value":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"},"value":{"svn":{"type":"exact-value","value":2},"digests":["sha-256-32;q83vAA==","sha-256-32;/////w=="],"flags":{"is-secure":false,"is-debug":true},"raw-value":{"type":"bytes","value":"AQIDBA=="},"raw-value-mask":"/////w==","mac-addr":"02:00:5e:10:00:00:00:01","ip-addr":"2001:db8::68","serial-number":"C02X70VHJHD5","ueid":"At6tvu/erQ==","uuid":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"}}}],"endorsed-values":[{"environment":{"class":{"id":{"type":"uuid","value":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"},"vendor":"ACME Ltd.","model":"RoadRunner","layer":0,"index":1},"instance":{"type":"ueid","value":"At6tvu/erQ=="},"group":{"type":"uuid","value":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"}},"measurement":{"key":{"type":"uuid","value":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"},"value":{"svn":{"type":"min-value","value":2},"digests":["sha-256-32;q83vAA==","sha-256-32;/////w=="],"flags":{"is-configured":false,"is-secure":false,"is-debug":true},"raw-value":{"type":"bytes","value":"AQIDBA=="},"raw-value-mask":"/////w==","mac-addr":"02:00:5e:10:00:00:00:01","ip-addr":"2001:db8::68","serial-number":"C02X70VHJHD5","ueid":"At6tvu/erQ==","uuid":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"}}}],"dev-identity-keys":[{"environment":{"instance":{"type":"ueid","value":"At6tvu/erQ=="}},"verification-keys":[{"type":"pkix-base64-key","value":"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEW1BvqF+/ry8BWa7ZEMU1xYYHEQ8B\nlLT4MFHOaO+ICTtIvrEeEpr/sfTAP66H2hCHdb5HEXKtRKod6QLcOLPA1Q==\n-----END PUBLIC KEY-----"}]}],"attester-verification-keys":[{"environment":{"instance":{"type":"uuid","value":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"}},"verification-keys":[{"type":"pkix-base64-key","value":"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEW1BvqF+/ry8BWa7ZEMU1xYYHEQ8B\nlLT4MFHOaO+ICTtIvrEeEpr/sfTAP66H2hCHdb5HEXKtRKod6QLcOLPA1Q==\n-----END PUBLIC KEY-----"}]}]}} + //a50065656e2d474201a10078206d792d6e733a61636d652d726f616472756e6e65722d737570706c656d656e740282a3006941434d45204c74642e01d8207468747470733a2f2f61636d652e6578616d706c6502820100a20069454d4341204c74642e0281020382a200781a6d792d6e733a61636d652d726f616472756e6e65722d626173650100a20078196d792d6e733a61636d652d726f616472756e6e65722d6f6c64010104a4008182a300a500d86f445502c000016941434d45204c74642e026a526f616452756e6e65720300040101d902264702deadbeefdead02d8255031fb5abf023e4992aa4e95f9c1503bfa81a200d8255031fb5abf023e4992aa4e95f9c1503bfa01aa01d90228020282820644abcdef00820644ffffffff03a201f403f504d9023044010203040544ffffffff064802005e1000000001075020010db8000000000000000000000068086c43303258373056484a484435094702deadbeefdead0a5031fb5abf023e4992aa4e95f9c1503bfa018182a300a500d8255031fb5abf023e4992aa4e95f9c1503bfa016941434d45204c74642e026a526f616452756e6e65720300040101d902264702deadbeefdead02d8255031fb5abf023e4992aa4e95f9c1503bfa81a200d8255031fb5abf023e4992aa4e95f9c1503bfa01aa01d90229020282820644abcdef00820644ffffffff03a300f401f403f504d9023044010203040544ffffffff064802005e1000000001075020010db8000000000000000000000068086c43303258373056484a484435094702deadbeefdead0a5031fb5abf023e4992aa4e95f9c1503bfa028182a101d902264702deadbeefdead81d9022a78b12d2d2d2d2d424547494e205055424c4943204b45592d2d2d2d2d0a4d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a304441516344516741455731427671462b2f727938425761375a454d553178595948455138420a6c4c54344d46484f614f2b4943547449767245654570722f7366544150363648326843486462354845584b74524b6f6436514c634f4c504131513d3d0a2d2d2d2d2d454e44205055424c4943204b45592d2d2d2d2d038182a101d8255031fb5abf023e4992aa4e95f9c1503bfa81d9022a78b12d2d2d2d2d424547494e205055424c4943204b45592d2d2d2d2d0a4d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a304441516344516741455731427671462b2f727938425761375a454d553178595948455138420a6c4c54344d46484f614f2b4943547449767245654570722f7366544150363648326843486462354845584b74524b6f6436514c634f4c504131513d3d0a2d2d2d2d2d454e44205055424c4943204b45592d2d2d2d2d + //{"lang":"en-GB","tag-identity":{"id":"my-ns:acme-roadrunner-supplement"},"entities":[{"name":"ACME Ltd.","regid":"https://acme.example","roles":["creator","tagCreator"]},{"name":"EMCA Ltd.","roles":["maintainer"]}],"linked-tags":[{"target":"my-ns:acme-roadrunner-base","rel":"supplements"},{"target":"my-ns:acme-roadrunner-old","rel":"replaces"}],"triples":{"reference-values":[{"environment":{"class":{"id":{"type":"oid","value":"2.5.2.8192"},"vendor":"ACME Ltd.","model":"RoadRunner","layer":0,"index":1},"instance":{"type":"ueid","value":"At6tvu/erQ=="},"group":{"type":"uuid","value":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"}},"measurements":[{"key":{"type":"uuid","value":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"},"value":{"svn":{"type":"exact-value","value":2},"digests":["sha-256-32;q83vAA==","sha-256-32;/////w=="],"flags":{"is-secure":false,"is-debug":true},"raw-value":{"type":"bytes","value":"AQIDBA=="},"raw-value-mask":"/////w==","mac-addr":"02:00:5e:10:00:00:00:01","ip-addr":"2001:db8::68","serial-number":"C02X70VHJHD5","ueid":"At6tvu/erQ==","uuid":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"}}]}],"endorsed-values":[{"environment":{"class":{"id":{"type":"uuid","value":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"},"vendor":"ACME Ltd.","model":"RoadRunner","layer":0,"index":1},"instance":{"type":"ueid","value":"At6tvu/erQ=="},"group":{"type":"uuid","value":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"}},"measurements":[{"key":{"type":"uuid","value":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"},"value":{"svn":{"type":"min-value","value":2},"digests":["sha-256-32;q83vAA==","sha-256-32;/////w=="],"flags":{"is-configured":false,"is-secure":false,"is-debug":true},"raw-value":{"type":"bytes","value":"AQIDBA=="},"raw-value-mask":"/////w==","mac-addr":"02:00:5e:10:00:00:00:01","ip-addr":"2001:db8::68","serial-number":"C02X70VHJHD5","ueid":"At6tvu/erQ==","uuid":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"}}]}],"dev-identity-keys":[{"environment":{"instance":{"type":"ueid","value":"At6tvu/erQ=="}},"verification-keys":[{"type":"pkix-base64-key","value":"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEW1BvqF+/ry8BWa7ZEMU1xYYHEQ8B\nlLT4MFHOaO+ICTtIvrEeEpr/sfTAP66H2hCHdb5HEXKtRKod6QLcOLPA1Q==\n-----END PUBLIC KEY-----"}]}],"attester-verification-keys":[{"environment":{"instance":{"type":"uuid","value":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"}},"verification-keys":[{"type":"pkix-base64-key","value":"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEW1BvqF+/ry8BWa7ZEMU1xYYHEQ8B\nlLT4MFHOaO+ICTtIvrEeEpr/sfTAP66H2hCHdb5HEXKtRKod6QLcOLPA1Q==\n-----END PUBLIC KEY-----"}]}]}} } func Example_encode_PSA() { @@ -117,23 +124,19 @@ func Example_encode_PSA() { SetVendor("ACME Ltd."). SetModel("RoadRunner 2.0"), }, - Measurement: *MustNewPSAMeasurement( - MustCreatePSARefValID( - TestSignerID, "BL", "5.0.5", - )).AddDigest(swid.Sha256_32, []byte{0xab, 0xcd, 0xef, 0x00}), - }, - ). - AddReferenceValue( - ValueTriple{ - Environment: Environment{ - Class: NewClassImplID(TestImplID). - SetVendor("ACME Ltd."). - SetModel("RoadRunner 2.0"), - }, - Measurement: *MustNewPSAMeasurement( - MustCreatePSARefValID( - TestSignerID, "PRoT", "1.3.5", - )).AddDigest(swid.Sha256_32, []byte{0xab, 0xcd, 0xef, 0x00}), + Measurements: *NewMeasurements(). + Add( + MustNewPSAMeasurement( + MustCreatePSARefValID( + TestSignerID, "BL", "5.0.5", + )).AddDigest(swid.Sha256_32, []byte{0xab, 0xcd, 0xef, 0x00}), + ). + Add( + MustNewPSAMeasurement( + MustCreatePSARefValID( + TestSignerID, "PRoT", "1.3.5", + )).AddDigest(swid.Sha256_32, []byte{0xab, 0xcd, 0xef, 0x00}), + ), }, ). AddAttestVerifKey( @@ -159,8 +162,8 @@ func Example_encode_PSA() { } // Output: - //a301a10078206d792d6e733a61636d652d726f616472756e6e65722d737570706c656d656e740281a3006941434d45204c74642e01d8207468747470733a2f2f61636d652e6578616d706c65028301000204a2008282a100a300d90258582061636d652d696d706c656d656e746174696f6e2d69642d303030303030303031016941434d45204c74642e026e526f616452756e6e657220322e30a200d90259a30162424c0465352e302e35055820acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b01a10281820644abcdef0082a100a300d90258582061636d652d696d706c656d656e746174696f6e2d69642d303030303030303031016941434d45204c74642e026e526f616452756e6e657220322e30a200d90259a3016450526f540465312e332e35055820acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b01a10281820644abcdef00038182a101d902264702deadbeefdead81d9022a78b12d2d2d2d2d424547494e205055424c4943204b45592d2d2d2d2d0a4d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a304441516344516741455731427671462b2f727938425761375a454d553178595948455138420a6c4c54344d46484f614f2b4943547449767245654570722f7366544150363648326843486462354845584b74524b6f6436514c634f4c504131513d3d0a2d2d2d2d2d454e44205055424c4943204b45592d2d2d2d2d - //{"tag-identity":{"id":"my-ns:acme-roadrunner-supplement"},"entities":[{"name":"ACME Ltd.","regid":"https://acme.example","roles":["creator","tagCreator","maintainer"]}],"triples":{"reference-values":[{"environment":{"class":{"id":{"type":"psa.impl-id","value":"YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE="},"vendor":"ACME Ltd.","model":"RoadRunner 2.0"}},"measurement":{"key":{"type":"psa.refval-id","value":{"label":"BL","version":"5.0.5","signer-id":"rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs="}},"value":{"digests":["sha-256-32;q83vAA=="]}}},{"environment":{"class":{"id":{"type":"psa.impl-id","value":"YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE="},"vendor":"ACME Ltd.","model":"RoadRunner 2.0"}},"measurement":{"key":{"type":"psa.refval-id","value":{"label":"PRoT","version":"1.3.5","signer-id":"rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs="}},"value":{"digests":["sha-256-32;q83vAA=="]}}}],"attester-verification-keys":[{"environment":{"instance":{"type":"ueid","value":"At6tvu/erQ=="}},"verification-keys":[{"type":"pkix-base64-key","value":"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEW1BvqF+/ry8BWa7ZEMU1xYYHEQ8B\nlLT4MFHOaO+ICTtIvrEeEpr/sfTAP66H2hCHdb5HEXKtRKod6QLcOLPA1Q==\n-----END PUBLIC KEY-----"}]}]}} + //a301a10078206d792d6e733a61636d652d726f616472756e6e65722d737570706c656d656e740281a3006941434d45204c74642e01d8207468747470733a2f2f61636d652e6578616d706c65028301000204a2008182a100a300d90258582061636d652d696d706c656d656e746174696f6e2d69642d303030303030303031016941434d45204c74642e026e526f616452756e6e657220322e3082a200d90259a30162424c0465352e302e35055820acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b01a10281820644abcdef00a200d90259a3016450526f540465312e332e35055820acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b01a10281820644abcdef00038182a101d902264702deadbeefdead81d9022a78b12d2d2d2d2d424547494e205055424c4943204b45592d2d2d2d2d0a4d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a304441516344516741455731427671462b2f727938425761375a454d553178595948455138420a6c4c54344d46484f614f2b4943547449767245654570722f7366544150363648326843486462354845584b74524b6f6436514c634f4c504131513d3d0a2d2d2d2d2d454e44205055424c4943204b45592d2d2d2d2d + //{"tag-identity":{"id":"my-ns:acme-roadrunner-supplement"},"entities":[{"name":"ACME Ltd.","regid":"https://acme.example","roles":["creator","tagCreator","maintainer"]}],"triples":{"reference-values":[{"environment":{"class":{"id":{"type":"psa.impl-id","value":"YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE="},"vendor":"ACME Ltd.","model":"RoadRunner 2.0"}},"measurements":[{"key":{"type":"psa.refval-id","value":{"label":"BL","version":"5.0.5","signer-id":"rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs="}},"value":{"digests":["sha-256-32;q83vAA=="]}},{"key":{"type":"psa.refval-id","value":{"label":"PRoT","version":"1.3.5","signer-id":"rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs="}},"value":{"digests":["sha-256-32;q83vAA=="]}}]}],"attester-verification-keys":[{"environment":{"instance":{"type":"ueid","value":"At6tvu/erQ=="}},"verification-keys":[{"type":"pkix-base64-key","value":"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEW1BvqF+/ry8BWa7ZEMU1xYYHEQ8B\nlLT4MFHOaO+ICTtIvrEeEpr/sfTAP66H2hCHdb5HEXKtRKod6QLcOLPA1Q==\n-----END PUBLIC KEY-----"}]}]}} } func Example_encode_PSA_attestation_verification() { @@ -398,64 +401,56 @@ var ( //go:embed testcases/comid-3.cbor testComid3 []byte -) -func Example_decode_CBOR_1() { - comid := Comid{} - err := comid.FromCBOR(testComid1) - if err != nil { - fmt.Printf("FAIL: %v", err) - } else { - fmt.Println("OK") - } - - // Output: OK -} + //go:embed testcases/comid-4.cbor + testComid4 []byte -func Example_decode_CBOR_2() { - comid := Comid{} - err := comid.FromCBOR(testComid2) - if err != nil { - fmt.Printf("FAIL: %v", err) - } else { - fmt.Println("OK") - } - - // Output: OK -} - -func Example_decode_CBOR_3() { - comid := Comid{} - err := comid.FromCBOR(testComidDesignCD) - if err != nil { - fmt.Printf("FAIL: %v", err) - } else { - fmt.Println("OK") - } - - // Output: OK -} + //go:embed testcases/comid-5.cbor + testComid5 []byte +) -func Example_decode_CBOR_4() { - comid := Comid{} - err := comid.FromCBOR(testComidFirmwareCD) - if err != nil { - fmt.Printf("FAIL: %v", err) - } else { - fmt.Println("OK") +func TestExample_decode_CBOR(_ *testing.T) { + tvs := []struct { + descr string + inp []byte + }{ + { + descr: "Test with CoMID-1 Diag", + inp: testComid1, + }, + { + descr: "Test with CoMID-2 Diag", + inp: testComid2, + }, + { + descr: "Test with CoMID-Design-CD Diag", + inp: testComidDesignCD, + }, + { + descr: "Test with Firmware-CD Diag", + inp: testComidFirmwareCD, + }, + { + descr: "Test with CoMID-3 Diag", + inp: testComid3, + }, + { + descr: "Test with CoMID-4 Diag", + inp: testComid4, + }, + { + descr: "Test with CoMID-5 Diag", + inp: testComid5, + }, } - - // Output: OK -} - -func Example_decode_CBOR_5() { - comid := Comid{} - err := comid.FromCBOR(testComid3) - if err != nil { - fmt.Printf("FAIL: %v", err) - } else { - fmt.Println("OK") + for _, tv := range tvs { + comid := Comid{} + err := comid.FromCBOR(tv.inp) + if err != nil { + fmt.Printf("FAIL: %v", err) + } else { + fmt.Println("OK") + } + // Output: OK } - - // Output: OK } diff --git a/comid/measurement.go b/comid/measurement.go index 15d511e..eaddd3b 100644 --- a/comid/measurement.go +++ b/comid/measurement.go @@ -773,3 +773,39 @@ func (o Measurement) Valid() error { return o.Val.Valid() } + +// Measurements is a container for Measurement instances and their extensions. +// It is a thin wrapper around extensions.Collection. +type Measurements extensions.Collection[Measurement, *Measurement] + +func NewMeasurements() *Measurements { + return (*Measurements)(extensions.NewCollection[Measurement]()) +} +func (o *Measurements) RegisterExtensions(exts extensions.Map) error { + return (*extensions.Collection[Measurement, *Measurement])(o).RegisterExtensions(exts) +} +func (o *Measurements) GetExtensions() extensions.IMapValue { + return (*extensions.Collection[Measurement, *Measurement])(o).GetExtensions() +} +func (o *Measurements) Valid() error { + return (*extensions.Collection[Measurement, *Measurement])(o).Valid() +} +func (o *Measurements) IsEmpty() bool { + return (*extensions.Collection[Measurement, *Measurement])(o).IsEmpty() +} +func (o *Measurements) Add(val *Measurement) *Measurements { + ret := (*extensions.Collection[Measurement, *Measurement])(o).Add(val) + return (*Measurements)(ret) +} +func (o Measurements) MarshalCBOR() ([]byte, error) { + return (extensions.Collection[Measurement, *Measurement])(o).MarshalCBOR() +} +func (o *Measurements) UnmarshalCBOR(data []byte) error { + return (*extensions.Collection[Measurement, *Measurement])(o).UnmarshalCBOR(data) +} +func (o Measurements) MarshalJSON() ([]byte, error) { + return (extensions.Collection[Measurement, *Measurement])(o).MarshalJSON() +} +func (o *Measurements) UnmarshalJSON(data []byte) error { + return (*extensions.Collection[Measurement, *Measurement])(o).UnmarshalJSON(data) +} diff --git a/comid/test_vars.go b/comid/test_vars.go index 8b993e6..7e2e2fe 100644 --- a/comid/test_vars.go +++ b/comid/test_vars.go @@ -234,75 +234,53 @@ var ( "model": "RoadRunner" } }, - "measurement": { - "key": { - "type": "psa.refval-id", + "measurements": [ + { + "key": { + "type": "psa.refval-id", + "value": { + "label": "BL", + "version": "2.1.0", + "signer-id": "rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=" + } + }, "value": { - "label": "BL", - "version": "2.1.0", - "signer-id": "rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=" + "digests": [ + "sha-256:h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc=" + ] } }, - "value": { - "digests": [ - "sha-256:h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc=" - ] - } - } - }, - { - "environment": { - "class": { - "id": { - "type": "psa.impl-id", - "value": "YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE=" + { + "key": { + "type": "psa.refval-id", + "value": { + "label": "PRoT", + "version": "1.3.5", + "signer-id": "rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=" + } }, - "vendor": "ACME", - "model": "RoadRunner" - } - }, - "measurement": { - "key": { - "type": "psa.refval-id", "value": { - "label": "PRoT", - "version": "1.3.5", - "signer-id": "rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=" + "digests": [ + "sha-256:AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8=" + ] } }, - "value": { - "digests": [ - "sha-256:AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8=" - ] - } - } - }, - { - "environment": { - "class": { - "id": { - "type": "psa.impl-id", - "value": "YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE=" + { + "key": { + "type": "psa.refval-id", + "value": { + "label": "ARoT", + "version": "0.1.4", + "signer-id": "rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=" + } }, - "vendor": "ACME", - "model": "RoadRunner" - } - }, - "measurement": { - "key": { - "type": "psa.refval-id", "value": { - "label": "ARoT", - "version": "0.1.4", - "signer-id": "rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=" + "digests": [ + "sha-256:o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg=" + ] } - }, - "value": { - "digests": [ - "sha-256:o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg=" - ] } - } + ] } ] } @@ -397,99 +375,65 @@ var ( "model": "RoadRunner" } }, - "measurement": { - "key": { - "type": "psa.refval-id", + "measurements": [ + { + "key": { + "type": "psa.refval-id", + "value": { + "label": "BL", + "version": "2.1.0", + "signer-id": "rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=" + } + }, "value": { - "label": "BL", - "version": "2.1.0", - "signer-id": "rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=" + "digests": [ + "sha-256:h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc=" + ] } }, - "value": { - "digests": [ - "sha-256:h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc=" - ] - } - } - }, - { - "environment": { - "class": { - "id": { - "type": "psa.impl-id", - "value": "YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE=" + { + "key": { + "type": "psa.refval-id", + "value": { + "label": "PRoT", + "version": "1.3.5", + "signer-id": "rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=" + } }, - "vendor": "ACME", - "model": "RoadRunner" - } - }, - "measurement": { - "key": { - "type": "psa.refval-id", "value": { - "label": "PRoT", - "version": "1.3.5", - "signer-id": "rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=" + "digests": [ + "sha-256:AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8=" + ] } }, - "value": { - "digests": [ - "sha-256:AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8=" - ] - } - } - }, - { - "environment": { - "class": { - "id": { - "type": "psa.impl-id", - "value": "YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE=" + { + "key": { + "type": "psa.refval-id", + "value": { + "label": "ARoT", + "version": "0.1.4", + "signer-id": "rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=" + } }, - "vendor": "ACME", - "model": "RoadRunner" - } - }, - "measurement": { - "key": { - "type": "psa.refval-id", "value": { - "label": "ARoT", - "version": "0.1.4", - "signer-id": "rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=" + "digests": [ + "sha-256:o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg=" + ] } }, - "value": { - "digests": [ - "sha-256:o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg=" - ] - } - } - }, - { - "environment": { - "class": { - "id": { - "type": "psa.impl-id", - "value": "YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE=" + { + "key": { + "type": "cca.platform-config-id", + "value": "a non-empty (unique) label" }, - "vendor": "ACME", - "model": "RoadRunner" - } - }, - "measurement": { - "key": { - "type": "cca.platform-config-id", - "value": "a non-empty (unique) label" - }, - "value": { - "raw-value": { - "type": "bytes", - "value": "cmF3dmFsdWUKcmF3dmFsdWUK" + "value": { + "raw-value": { + "type": "bytes", + "value": "cmF3dmFsdWUKcmF3dmFsdWUK" + } } } - } + ] } ] } @@ -500,35 +444,36 @@ var ( "tag-identity": { "id": "99019224-57AA-44BC-BEF8-D36BDD6BD035", "version": 0 - }, - "entities": [ +}, +"entities": [ + { + "name": "Workload Client Ltd.", + "regid": "https://workloadclient.example", + "roles": [ + "tagCreator", + "creator", + "maintainer" + ] + } +], +"triples": { + "reference-values": [ { - "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" + "environment": { + "class": { + "id": { + "type": "uuid", + "value": "CD1F0E55-26F9-460D-B9D8-F7FDE171787C" }, - "instance": { - "type": "bytes", - "value": "QoS1aUymwNLPR4mguVrIAlyBjeUjBDZL580pgbLS7caFsyInfsJYGZYkE9jJssH1" - } + "vendor": "Workload Client Ltd" }, - "measurement": { + "instance": { + "type": "bytes", + "value": "QoS1aUymwNLPR4mguVrIAlyBjeUjBDZL580pgbLS7caFsyInfsJYGZYkE9jJssH1" + } + }, + "measurements": [ + { "value": { "raw-value": { "type": "bytes", @@ -568,9 +513,10 @@ var ( } } } - } - ] - } + ] + } + ] + } } ` ) diff --git a/comid/testcases/comid-1.cbor b/comid/testcases/comid-1.cbor index 033b8dd..58dba91 100644 Binary files a/comid/testcases/comid-1.cbor and b/comid/testcases/comid-1.cbor differ diff --git a/comid/testcases/comid-2.cbor b/comid/testcases/comid-2.cbor index b3a34c6..4c8e045 100644 Binary files a/comid/testcases/comid-2.cbor and b/comid/testcases/comid-2.cbor differ diff --git a/comid/testcases/comid-3.cbor b/comid/testcases/comid-3.cbor index f47d1d1..4277e67 100644 Binary files a/comid/testcases/comid-3.cbor and b/comid/testcases/comid-3.cbor differ diff --git a/comid/testcases/comid-4.cbor b/comid/testcases/comid-4.cbor new file mode 100644 index 0000000..8749e6b Binary files /dev/null and b/comid/testcases/comid-4.cbor differ diff --git a/comid/testcases/comid-5.cbor b/comid/testcases/comid-5.cbor new file mode 100644 index 0000000..f4f514c Binary files /dev/null and b/comid/testcases/comid-5.cbor differ diff --git a/comid/testcases/comid-design-cd.cbor b/comid/testcases/comid-design-cd.cbor index d736d6c..643199a 100644 Binary files a/comid/testcases/comid-design-cd.cbor and b/comid/testcases/comid-design-cd.cbor differ diff --git a/comid/testcases/comid-firmware-cd.cbor b/comid/testcases/comid-firmware-cd.cbor index cb876a6..f9a68a7 100644 Binary files a/comid/testcases/comid-firmware-cd.cbor and b/comid/testcases/comid-firmware-cd.cbor differ diff --git a/comid/testcases/src/comid-1.diag b/comid/testcases/src/comid-1.diag index c756da1..759617b 100644 --- a/comid/testcases/src/comid-1.diag +++ b/comid/testcases/src/comid-1.diag @@ -20,18 +20,20 @@ / comid.layer / 3 : 1 } }, - / measurement-map / { - / comid.mval / 1 : { - / comid.ver / 0 : { - / comid.version / 0 : "1.0.0", - / comid.version-scheme / 1 : 16384 / semver / - }, - / comid.digests / 2 : [ [ - / hash-alg-id / 1, / sha256 / - / hash-value / h'44aa336af4cb14a879432e53dd6571c7fa9bccafb75f488259262d6ea3a4d91b' - ] ] + [ + / measurement-map / { + / comid.mval / 1 : { + / comid.ver / 0 : { + / comid.version / 0 : "1.0.0", + / comid.version-scheme / 1 : 16384 / semver / + }, + / comid.digests / 2 : [ [ + / hash-alg-id / 1, / sha256 / + / hash-value / h'44aa336af4cb14a879432e53dd6571c7fa9bccafb75f488259262d6ea3a4d91b' + ]] + } } - } + ] ] ] } } diff --git a/comid/testcases/src/comid-2.diag b/comid/testcases/src/comid-2.diag index ce3c275..f5309a0 100644 --- a/comid/testcases/src/comid-2.diag +++ b/comid/testcases/src/comid-2.diag @@ -21,14 +21,16 @@ / comid.layer / 3 : 1 } }, - / measurement-map / { - / comid.mval / 1 : { - / comid.digests / 2 : [ [ - / hash-alg-id / 1, / sha256 / - / hash-value / h'44aa336af4cb14a879432e53dd6571c7fa9bccafb75f488259262d6ea3a4d91b' - ] ] + [ + / measurement-map / { + / comid.mval / 1 : { + / comid.digests / 2 : [ [ + / hash-alg-id / 1, / sha256 / + / hash-value / h'44aa336af4cb14a879432e53dd6571c7fa9bccafb75f488259262d6ea3a4d91b' + ] ] + } } - } + ] ], [ / environment-map / { @@ -43,14 +45,16 @@ / comid.index / 4 : 0 } }, - / measurement-map / { - / comid.mval / 1 : { - / comid.digests / 2 : [ [ - / hash-alg-id / 1, / sha256 / - / hash-value / h'bb71198ed60a95dc3c619e555c2c0b8d7564a38031b034a195892591c65365b0' - ] ] + [ + / measurement-map / { + / comid.mval / 1 : { + / comid.digests / 2 : [ [ + / hash-alg-id / 1, / sha256 / + / hash-value / h'bb71198ed60a95dc3c619e555c2c0b8d7564a38031b034a195892591c65365b0' + ] ] + } } - } + ] ], [ / environment-map / { @@ -65,14 +69,16 @@ / comid.index / 4 : 1 } }, - / measurement-map / { - / comid.mval / 1 : { - / comid.digests / 2 : [ [ - / hash-alg-id / 1, / sha256 / - / hash-value / h'bb71198ed60a95dc3c619e555c2c0b8d7564a38031b034a195892591c65365b0' - ] ] + [ + / measurement-map / { + / comid.mval / 1 : { + / comid.digests / 2 : [ [ + / hash-alg-id / 1, / sha256 / + / hash-value / h'bb71198ed60a95dc3c619e555c2c0b8d7564a38031b034a195892591c65365b0' + ] ] + } } - } + ] ] ], / comid.endorsed-triples / 1 : [ [ @@ -87,11 +93,13 @@ / comid.layer / 3 : 0 } }, - / measurement-map / { - / comid.mval / 1 : { - / comid.svn / 1 : 552(1) + [ + / measurement-map / { + / comid.mval / 1 : { + / comid.svn / 1 : 552(1) + } } - } + ] ] ] } } diff --git a/comid/testcases/src/comid-3.diag b/comid/testcases/src/comid-3.diag index c11fc23..ec0e66d 100644 --- a/comid/testcases/src/comid-3.diag +++ b/comid/testcases/src/comid-3.diag @@ -20,14 +20,16 @@ / comid.model / 2 : "ACME RoadRunner Firmware" } }, - / measurement-map / { - / comid.mkey / 0: 700, - / comid.mval / 1 : { - / comid.digests / 2 : [[ - / hash-alg-id / 6, / sha-256-32 / - / hash-value / h'ABCDEF00' ]] + [ + / measurement-map / { + / comid.mkey / 0: 700, + / comid.mval / 1 : { + / comid.digests / 2 : [[ + / hash-alg-id / 6, / sha-256-32 / + / hash-value / h'ABCDEF00' ]] + } } - } + ] ] ] } diff --git a/comid/testcases/src/comid-4.diag b/comid/testcases/src/comid-4.diag new file mode 100644 index 0000000..9c3cd9f --- /dev/null +++ b/comid/testcases/src/comid-4.diag @@ -0,0 +1,51 @@ +/ concise-mid-tag / { + / comid.tag-identity / 1 : { + / comid.tag-id / 0 : h'3f06af63a93c11e4979700505690773f' + }, + / comid.entity / 2 : [ { + / comid.entity-name / 0 : "ACME Inc.", + / comid.reg-id / 1 : 32("https://acme.example"), + / comid.role / 2 : [ 0 ] / tag-creator / + } ], + / comid.triples / 4 : { + / comid.reference-triples / 0 : [ [ + / environment-map / { + / comid.class / 0 : { + / comid.class-id / 0 : + / tagged-uuid-type / 37( + h'67b28b6c34cc40a19117ab5b05911e37' + ), + / comid.vendor / 1 : "ACME Inc.", + / comid.model / 2 : "ACME RoadRunner", + / comid.layer / 3 : 1 + } + }, + [ + / measurement-map A / { + / comid.mval / 1 : { + / comid.ver / 0 : { + / comid.version / 0 : "1.0.0", + / comid.version-scheme / 1 : 16384 / semver / + }, + / comid.digests / 2 : [ [ + / hash-alg-id / 1, / sha256 / + / hash-value / h'44aa336af4cb14a879432e53dd6571c7fa9bccafb75f488259262d6ea3a4d91b' + ] ] + } + }, + / measurement-map B / { + / comid.mval / 1 : { + / comid.ver / 0 : { + / comid.version / 0 : "2.0.0", + / comid.version-scheme / 1 : 16384 / semver / + }, + / comid.digests / 2 : [ [ + / hash-alg-id / 1, / sha256 / + / hash-value / h'FFaa336af4cb14a879432e53dd6571c7fa9bccafb75f488259262d6ea3a4d91b' + ] ] + } + } + ] + ] ] + } +} \ No newline at end of file diff --git a/comid/testcases/src/comid-5.diag b/comid/testcases/src/comid-5.diag new file mode 100644 index 0000000..b979247 --- /dev/null +++ b/comid/testcases/src/comid-5.diag @@ -0,0 +1,53 @@ +/ concise-mid-tag / { + / comid.tag-identity / 1 : { + / comid.tag-id / 0 : h'3f06af63a93c11e4979700505690773f' + }, + / comid.entity / 2 : [ { + / comid.entity-name / 0 : "ACME Inc.", + / comid.reg-id / 1 : 32("https://acme.example"), + / comid.role / 2 : [ 0 ] / tag-creator / + } ], + / comid.triples / 4 : { + / comid.reference-triples / 0 : [ [ + / environment-map / { + / comid.class / 0 : { + / comid.class-id / 0 : + / tagged-uuid-type / 37( + h'67b28b6c34cc40a19117ab5b05911e37' + ), + / comid.vendor / 1 : "ACME Inc.", + / comid.model / 2 : "ACME RoadRunner", + / comid.layer / 3 : 1 + } + }, + [ + / measurement-map A / { + /comid.mkey / 0 : 1, + / comid.mval / 1 : { + / comid.ver / 0 : { + / comid.version / 0 : "1.0.0", + / comid.version-scheme / 1 : 16384 / semver / + }, + / comid.digests / 2 : [ [ + / hash-alg-id / 1, / sha256 / + / hash-value / h'44aa336af4cb14a879432e53dd6571c7fa9bccafb75f488259262d6ea3a4d91b' + ] ] + } + }, + / measurement-map B / { + /comid.mkey / 0 : 2, + / comid.mval / 1 : { + / comid.ver / 0 : { + / comid.version / 0 : "2.0.0", + / comid.version-scheme / 1 : 16384 / semver / + }, + / comid.digests / 2 : [ [ + / hash-alg-id / 1, / sha256 / + / hash-value / h'FFaa336af4cb14a879432e53dd6571c7fa9bccafb75f488259262d6ea3a4d91b' + ] ] + } + } + ] + ] ] + } +} \ No newline at end of file diff --git a/comid/testcases/src/comid-design-cd.diag b/comid/testcases/src/comid-design-cd.diag index d3305b5..cae08c4 100644 --- a/comid/testcases/src/comid-design-cd.diag +++ b/comid/testcases/src/comid-design-cd.diag @@ -24,7 +24,8 @@ / comid.layer / 3 : 2 } }, - / measurement-map / + [ + / measurement-map / { / comid.mval / 1 : { / raw-value-group / @@ -32,6 +33,7 @@ / comid.raw-value-mask / 5 : h'FFFFFFFF00000000' } } + ] ], [ / environment-map / { @@ -43,17 +45,19 @@ / comid.layer / 3 : 2 } }, - / measurement-map / - { - / comid.mval / 1 : { - / comid.digests / 2 : [ - [ - / hash-alg-id / 7, / SHA384 / - / hash-value / h'3FE18ECA4053879E017EF5EB7A3E5157659C5F9BB15B7D09959B8B8647822A4CC21C3AA6721CEF87F5BFA53495DB0833' - ] - ] + [ + / measurement-map / + { + / comid.mval / 1 : { + / comid.digests / 2 : [ + [ + / hash-alg-id / 7, / SHA384 / + / hash-value / h'3FE18ECA4053879E017EF5EB7A3E5157659C5F9BB15B7D09959B8B8647822A4CC21C3AA6721CEF87F5BFA53495DB0833' + ] + ] + } } - } + ] ], [ / environment-map / { @@ -65,17 +69,19 @@ / comid.layer / 3 : 2 } }, - / measurement-map / - { - / comid.mval / 1 : { - / comid.digests / 2 : [ - [ - / hash-alg-id / 7, / SHA384 / - / hash-value / h'20FF681A0882E29B481953888936209CB53DF9C5AAEC606A2C24A0FB138595124B8E3F24A12771BC3854CC68B40361AD' - ] - ] + [ + / measurement-map / + { + / comid.mval / 1 : { + / comid.digests / 2 : [ + [ + / hash-alg-id / 7, / SHA384 / + / hash-value / h'20FF681A0882E29B481953888936209CB53DF9C5AAEC606A2C24A0FB138595124B8E3F24A12771BC3854CC68B40361AD' + ] + ] + } } - } + ] ], [ / environment-map / { @@ -86,14 +92,16 @@ / comid.vendor / 1 : "fpgadesignsrus.example" } }, - / measurement-map / - { - / comid.mval / 1 : { - / raw-value-group / - / comid.raw-value / 4 : 560(h'000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), - / comid.raw-value-mask / 5 : h'466224343D681802C1506BBED7D7F00B969BADDD6346E4F2E7CE146692996F22A45814DE81D248F583B65F817B5FCEAB' + [ + / measurement-map / + { + / comid.mval / 1 : { + / raw-value-group / + / comid.raw-value / 4 : 560(h'000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), + / comid.raw-value-mask / 5 : h'466224343D681802C1506BBED7D7F00B969BADDD6346E4F2E7CE146692996F22A45814DE81D248F583B65F817B5FCEAB' + } } - } + ] ] ], / comid.endorsed-triples / 1 : [ @@ -106,13 +114,15 @@ / comid.vendor / 1 : "fpgadesignsrus.example" } }, - / measurement-map / { - / comid.mval / 1 : { - / raw-value-group / - / comid.raw-value / 4 : 560(h'0000000000000000'), - / comid.raw-value-mask / 5 : h'FFFFFFFF00000000' + [ + / measurement-map / { + / comid.mval / 1 : { + / raw-value-group / + / comid.raw-value / 4 : 560(h'0000000000000000'), + / comid.raw-value-mask / 5 : h'FFFFFFFF00000000' + } } - } + ] ] ] } diff --git a/comid/testcases/src/comid-firmware-cd.diag b/comid/testcases/src/comid-firmware-cd.diag index 1e8625f..d61ab7d 100644 --- a/comid/testcases/src/comid-firmware-cd.diag +++ b/comid/testcases/src/comid-firmware-cd.diag @@ -20,18 +20,20 @@ / comid.index / 4 : 0 } }, - / measurement-map / - { - / comid.mval / 1 : { - / comid.svn / 1 : 552(1), - / comid.digests / 2 : [ - [ - / hash-alg-id / 7, / SHA384 / - / hash-value / h'15E77D6F133252F1DB7044901313884F2977D2109B33C79F33E079BFC78865255C0FB733C240FDDA544B8215D7B8F815' + [ + / measurement-map / + { + / comid.mval / 1 : { + / comid.svn / 1 : 552(1), + / comid.digests / 2 : [ + [ + / hash-alg-id / 7, / SHA384 / + / hash-value / h'15E77D6F133252F1DB7044901313884F2977D2109B33C79F33E079BFC78865255C0FB733C240FDDA544B8215D7B8F815' + ] ] - ] + } } - } + ] ], [ / environment-map / { @@ -43,18 +45,20 @@ / comid.index / 4 : 0 } }, - / measurement-map / - { - / comid.mval / 1 : { - / comid.svn / 1 : 552(1), - / comid.digests / 2 : [ - [ - / hash-alg-id / 7, / SHA384 / - / hash-value / h'3D90B6BF003DA2D94EA5463F97FB3C53DDC51CFBA1E3E38EEF7AF071A67986595D22729131DF9FE80F5451EEF154F85E' + [ + / measurement-map / + { + / comid.mval / 1 : { + / comid.svn / 1 : 552(1), + / comid.digests / 2 : [ + [ + / hash-alg-id / 7, / SHA384 / + / hash-value / h'3D90B6BF003DA2D94EA5463F97FB3C53DDC51CFBA1E3E38EEF7AF071A67986595D22729131DF9FE80F5451EEF154F85E' + ] ] - ] + } } - } + ] ] ], / comid.endorsed-triples / 1 : [ @@ -67,13 +71,15 @@ / comid.vendor / 1 : "fwmfginc.example" } }, - / measurement-map / { - / comid.mval / 1 : { - / raw-value-group / - / comid.raw-value / 4 : 560(h'0000000000000000'), - / comid.raw-value-mask / 5 : h'FFFFFFFF00000000' - } - } + [ + / measurement-map / { + / comid.mval / 1 : { + / raw-value-group / + / comid.raw-value / 4 : 560(h'0000000000000000'), + / comid.raw-value-mask / 5 : h'FFFFFFFF00000000' + } + } + ] ] ] } diff --git a/comid/valuetriple.go b/comid/valuetriple.go index 9e175ce..85ad0f3 100644 --- a/comid/valuetriple.go +++ b/comid/valuetriple.go @@ -4,37 +4,40 @@ package comid import ( + "errors" "fmt" "github.com/veraison/corim/extensions" ) -// ValueTriple relates a measurement to a target environment, essentially -// forming a subject-predicate-object triple of -// "measurement-pertains-to-environment". This structure is used to represent -// both reference-triple-record and endorsed-triple-record in the CoRIM spec -// (as of rev. 04). +// ValueTriple relates measurements to a target environment, essentially +// forming a subject-predicate-object triple of "measurements-pertain +// to-environment". This structure is used to represent both +// reference-triple-record and endorsed-triple-record in the CoRIM spec (as of +// rev. 04). type ValueTriple struct { - _ struct{} `cbor:",toarray"` - Environment Environment `json:"environment"` - Measurement Measurement `json:"measurement"` + _ struct{} `cbor:",toarray"` + Environment Environment `json:"environment"` + Measurements Measurements `json:"measurements"` } func (o *ValueTriple) RegisterExtensions(exts extensions.Map) error { - return o.Measurement.RegisterExtensions(exts) + return o.Measurements.RegisterExtensions(exts) } func (o *ValueTriple) GetExtensions() extensions.IMapValue { - return o.Measurement.GetExtensions() + return o.Measurements.GetExtensions() } - func (o ValueTriple) Valid() error { if err := o.Environment.Valid(); err != nil { return fmt.Errorf("environment validation failed: %w", err) } - if err := o.Measurement.Valid(); err != nil { - return fmt.Errorf("measurement validation failed: %w", err) + if o.Measurements.IsEmpty() { + return errors.New("measurements validation failed: no measurement entries") + } + if err := o.Measurements.Valid(); err != nil { + return fmt.Errorf("measurements validation failed: %w", err) } return nil diff --git a/comid/valuetriple_test.go b/comid/valuetriple_test.go index 857bcf2..0888e32 100644 --- a/comid/valuetriple_test.go +++ b/comid/valuetriple_test.go @@ -19,5 +19,5 @@ func Test_ReferenceValue(t *testing.T) { require.NoError(t, err) rv.Environment.Instance = MustNewUUIDInstance(id) err = rv.Valid() - assert.EqualError(t, err, "measurement validation failed: no measurement value set") + assert.EqualError(t, err, "measurements validation failed: no measurement entries") } diff --git a/corim/example_profile_test.go b/corim/example_profile_test.go index b62a9da..becff46 100644 --- a/corim/example_profile_test.go +++ b/corim/example_profile_test.go @@ -104,10 +104,10 @@ func Example_profile_unmarshal() { Extensions.MustGetString("Address")) fmt.Printf("Measurements:\n") - for _, refVal := range extractedComid.Triples.ReferenceValues.Values { + for _, m := range extractedComid.Triples.ReferenceValues.Values[0].Measurements.Values { - val := hex.EncodeToString((*refVal.Measurement.Val.Digests)[0].HashValue) - tsInt := refVal.Measurement.Val.Extensions.MustGetInt64("timestamp") + val := hex.EncodeToString((*m.Val.Digests)[0].HashValue) + tsInt := m.Val.Extensions.MustGetInt64("timestamp") ts := time.Unix(tsInt, 0).UTC() fmt.Printf(" %v taken at %s\n", val, ts.Format("2006-01-02T15:04:05")) @@ -152,6 +152,15 @@ func Example_profile_marshal() { log.Fatalf("could not set entity Address: %v", err) } + refVal := comid.ValueTriple{ + Environment: comid.Environment{ + Class: comid.NewClassImplID(comid.TestImplID). + SetVendor("ACME Ltd."). + SetModel("RoadRunner 2.0"), + }, + Measurements: *comid.NewMeasurements(), + } + measurement := comid.MustNewPSAMeasurement( comid.MustCreatePSARefValID( comid.TestSignerID, "BL", "5.0.5", @@ -168,15 +177,7 @@ func Example_profile_marshal() { log.Fatal("could not register refval extensions") } - refVal := comid.ValueTriple{ - Environment: comid.Environment{ - Class: comid.NewClassImplID(comid.TestImplID). - SetVendor("ACME Ltd."). - SetModel("RoadRunner 2.0"), - }, - Measurement: *measurement, - } - + refVal.Measurements.Add(measurement) myComid.Triples.AddReferenceValue(refVal) err = myComid.Valid() @@ -194,5 +195,5 @@ func Example_profile_marshal() { fmt.Printf("corim: %v", hex.EncodeToString(buf)) // output: - // corim: a300f6018158d8d901faa40065656e2d474201a100676578616d706c650281a4006941434d45204c74642e01d8207468747470733a2f2f61636d652e6578616d706c65028101206f3132332046616b652053747265657404a1008182a100a300d90258582061636d652d696d706c656d656e746174696f6e2d69642d303030303030303031016941434d45204c74642e026e526f616452756e6e657220322e30a200d90259a30162424c0465352e302e35055820acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b01a10281820644abcdef00037822687474703a2f2f6578616d706c652e636f6d2f6578616d706c652d70726f66696c65 + // corim: a300f6018158d9d901faa40065656e2d474201a100676578616d706c650281a4006941434d45204c74642e01d8207468747470733a2f2f61636d652e6578616d706c65028101206f3132332046616b652053747265657404a1008182a100a300d90258582061636d652d696d706c656d656e746174696f6e2d69642d303030303030303031016941434d45204c74642e026e526f616452756e6e657220322e3081a200d90259a30162424c0465352e302e35055820acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b01a10281820644abcdef00037822687474703a2f2f6578616d706c652e636f6d2f6578616d706c652d70726f66696c65 } diff --git a/corim/profiles_test.go b/corim/profiles_test.go index 34c5e89..4b4a917 100644 --- a/corim/profiles_test.go +++ b/corim/profiles_test.go @@ -126,7 +126,7 @@ func TestProfile_marshaling(t *testing.T) { address := cmd.Entities.Values[0].Extensions.MustGetString("Address") assert.Equal(t, "123 Fake Street", address) - ts := cmd.Triples.ReferenceValues.Values[0].Measurement. + ts := cmd.Triples.ReferenceValues.Values[0].Measurements.Values[0]. Val.Extensions.MustGetInt("timestamp") assert.Equal(t, 1720782190, ts) @@ -169,7 +169,7 @@ func TestProfile_marshaling(t *testing.T) { address = cmd.Entities.Values[0].Extensions.MustGetString("Address") assert.Equal(t, "123 Fake Street", address) - ts = cmd.Triples.ReferenceValues.Values[0].Measurement. + ts = cmd.Triples.ReferenceValues.Values[0].Measurements.Values[0]. Val.Extensions.MustGetInt("timestamp") assert.Equal(t, 1720782190, ts) diff --git a/corim/testcases/comid-ext.json b/corim/testcases/comid-ext.json index a670c1c..541113e 100644 --- a/corim/testcases/comid-ext.json +++ b/corim/testcases/comid-ext.json @@ -29,19 +29,21 @@ "model": "RoadRunner" } }, - "measurement": { - "key": { - "type": "cca.platform-config-id", - "value": "cfg v1.0.0" - }, - "value": { - "timestamp": 1720782190, - "raw-value": { - "type": "bytes", - "value": "cmF3dmFsdWUKcmF3dmFsdWUK" - } - } - } + "measurements": [ + { + "key": { + "type": "cca.platform-config-id", + "value": "cfg v1.0.0" + }, + "value": { + "timestamp": 1720782190, + "raw-value": { + "type": "bytes", + "value": "cmF3dmFsdWUKcmF3dmFsdWUK" + } + } + } + ] } ] } diff --git a/corim/testcases/comid.json b/corim/testcases/comid.json index 9c4125b..dedf63d 100644 --- a/corim/testcases/comid.json +++ b/corim/testcases/comid.json @@ -28,18 +28,21 @@ "model": "RoadRunner" } }, - "measurement": { - "key": { - "type": "cca.platform-config-id", - "value": "cfg v1.0.0" - }, - "value": { - "raw-value": { - "type": "bytes", - "value": "cmF3dmFsdWUKcmF3dmFsdWUK" - } - } - } + "measurements": [ + { + "key": { + "type": "cca.platform-config-id", + "value": "cfg v1.0.0" + }, + "value": { + "timestamp": 1720782190, + "raw-value": { + "type": "bytes", + "value": "cmF3dmFsdWUKcmF3dmFsdWUK" + } + } + } + ] } ] } diff --git a/corim/testcases/signed-corim-with-extensions.cbor b/corim/testcases/signed-corim-with-extensions.cbor index eb03f4a..d88487f 100644 Binary files a/corim/testcases/signed-corim-with-extensions.cbor and b/corim/testcases/signed-corim-with-extensions.cbor differ diff --git a/corim/testcases/signed-example-corim.cbor b/corim/testcases/signed-example-corim.cbor index 22a2287..ff1e0f4 100644 Binary files a/corim/testcases/signed-example-corim.cbor and b/corim/testcases/signed-example-corim.cbor differ diff --git a/corim/testcases/signed-good-corim.cbor b/corim/testcases/signed-good-corim.cbor index f08557b..09c0b07 100644 Binary files a/corim/testcases/signed-good-corim.cbor and b/corim/testcases/signed-good-corim.cbor differ diff --git a/corim/testcases/src/corim-with-extensions.yaml b/corim/testcases/src/corim-with-extensions.yaml index 0eec372..7c09bf5 100644 --- a/corim/testcases/src/corim-with-extensions.yaml +++ b/corim/testcases/src/corim-with-extensions.yaml @@ -33,57 +33,42 @@ YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE= 1: ACME 2: RoadRunner - - 0: - tag: 601 - value: - 1: BL - 4: 2.1.0 - 5: !!binary |- - rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= - 1: - 2: - - - 1 - - !!binary |- - h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc= - -1: 1720782190 - - - 0: - 0: - tag: 600 - value: !!binary |- - YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE= - 1: ACME - 2: RoadRunner - - 0: - tag: 601 - value: - 1: PRoT - 4: 1.3.5 - 5: !!binary |- - rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= - 1: - 2: - - - 1 - - !!binary |- - AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8= - -1: 1720782190 - - - 0: - 0: - tag: 600 - value: !!binary |- - YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE= - 1: ACME - 2: RoadRunner - - 0: - tag: 601 - value: - 1: ARoT - 4: 0.1.4 - 5: !!binary |- - rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= - 1: - 2: - - - 1 - - !!binary |- - o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg= - -1: 1720782190 - + - - 0: + tag: 601 + value: + 1: BL + 4: 2.1.0 + 5: !!binary |- + rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= + 1: + 2: + - - 1 + - !!binary |- + h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc= + -1: 1720782190 + - 0: + tag: 601 + value: + 1: PRoT + 4: 1.3.5 + 5: !!binary |- + rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= + 1: + 2: + - - 1 + - !!binary |- + AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8= + -1: 1720782190 + - 0: + tag: 601 + value: + 1: ARoT + 4: 0.1.4 + 5: !!binary |- + rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= + 1: + 2: + - - 1 + - !!binary |- + o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg= + -1: 1720782190 diff --git a/corim/testcases/src/example-corim.yaml b/corim/testcases/src/example-corim.yaml index 7dff794..091f1da 100644 --- a/corim/testcases/src/example-corim.yaml +++ b/corim/testcases/src/example-corim.yaml @@ -36,57 +36,42 @@ YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE= 1: ACME 2: RoadRunner - - 0: - tag: 601 - value: - 1: BL - 4: 2.1.0 - 5: !!binary |- - rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= - 1: - 2: - - - 1 - - !!binary |- - h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc= - -1: 1720782190 - - - 0: - 0: - tag: 600 - value: !!binary |- - YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE= - 1: ACME - 2: RoadRunner - - 0: - tag: 601 - value: - 1: PRoT - 4: 1.3.5 - 5: !!binary |- - rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= - 1: - 2: - - - 1 - - !!binary |- - AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8= - -1: 1720782190 - - - 0: - 0: - tag: 600 - value: !!binary |- - YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE= - 1: ACME - 2: RoadRunner - - 0: - tag: 601 - value: - 1: ARoT - 4: 0.1.4 - 5: !!binary |- - rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= - 1: - 2: - - - 1 - - !!binary |- - o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg= - -1: 1720782190 - + - - 0: + tag: 601 + value: + 1: BL + 4: 2.1.0 + 5: !!binary |- + rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= + 1: + 2: + - - 1 + - !!binary |- + h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc= + -1: 1720782190 + - 0: + tag: 601 + value: + 1: PRoT + 4: 1.3.5 + 5: !!binary |- + rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= + 1: + 2: + - - 1 + - !!binary |- + AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8= + -1: 1720782190 + - 0: + tag: 601 + value: + 1: ARoT + 4: 0.1.4 + 5: !!binary |- + rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= + 1: + 2: + - - 1 + - !!binary |- + o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg= + -1: 1720782190 diff --git a/corim/testcases/src/good-corim.yaml b/corim/testcases/src/good-corim.yaml index ca12ebe..a04e9cb 100644 --- a/corim/testcases/src/good-corim.yaml +++ b/corim/testcases/src/good-corim.yaml @@ -27,54 +27,39 @@ YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE= 1: ACME 2: RoadRunner - - 0: - tag: 601 - value: - 1: BL - 4: 2.1.0 - 5: !!binary |- - rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= - 1: - 2: - - - 1 - - !!binary |- - h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc= - - - 0: - 0: - tag: 600 - value: !!binary |- - YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE= - 1: ACME - 2: RoadRunner - - 0: - tag: 601 - value: - 1: PRoT - 4: 1.3.5 - 5: !!binary |- - rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= - 1: - 2: - - - 1 - - !!binary |- - AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8= - - - 0: - 0: - tag: 600 - value: !!binary |- - YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE= - 1: ACME - 2: RoadRunner - - 0: - tag: 601 - value: - 1: ARoT - 4: 0.1.4 - 5: !!binary |- - rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= - 1: - 2: - - - 1 - - !!binary |- - o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg= - + - - 0: + tag: 601 + value: + 1: BL + 4: 2.1.0 + 5: !!binary |- + rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= + 1: + 2: + - - 1 + - !!binary |- + h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc= + - 0: + tag: 601 + value: + 1: PRoT + 4: 1.3.5 + 5: !!binary |- + rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= + 1: + 2: + - - 1 + - !!binary |- + AmOCmYm2/ZVPcrqvL8ZLwuLwHWktTecphuqAj26ZgT8= + - 0: + tag: 601 + value: + 1: ARoT + 4: 0.1.4 + 5: !!binary |- + rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs= + 1: + 2: + - - 1 + - !!binary |- + o6XnFfDMV0pzw/m+u2vCTzL/1bZ7OHJEwskJ2neaFHg= diff --git a/corim/testcases/unsigned-corim-with-extensions.cbor b/corim/testcases/unsigned-corim-with-extensions.cbor index a67d063..bfc9488 100644 Binary files a/corim/testcases/unsigned-corim-with-extensions.cbor and b/corim/testcases/unsigned-corim-with-extensions.cbor differ diff --git a/corim/testcases/unsigned-example-corim.cbor b/corim/testcases/unsigned-example-corim.cbor index fff8f2e..e8d28f5 100644 Binary files a/corim/testcases/unsigned-example-corim.cbor and b/corim/testcases/unsigned-example-corim.cbor differ diff --git a/corim/testcases/unsigned-good-corim.cbor b/corim/testcases/unsigned-good-corim.cbor index 8eb022c..9e9e1c8 100644 Binary files a/corim/testcases/unsigned-good-corim.cbor and b/corim/testcases/unsigned-good-corim.cbor differ