Skip to content

Commit

Permalink
fix(comid): bring ValueTriple into alignment with rev04
Browse files Browse the repository at this point in the history
At rev00, for reference/endorsed value triples, the CoRIM spec
associated an environment with one or more measurements, allowing for
two layers of multiplicity.

Since rev01, and up to (current) rev04, the spec removed the second
layer, now associating an environment with exactly one measurement.

This commit brings our implementation into alignment with the spec,
replacing ValueTriple.Measurements collection with the single
ValueTriple.Measurement.

Signed-off-by: Sergei Trofimov <[email protected]>
  • Loading branch information
setrofim committed Aug 14, 2024
1 parent 2583a73 commit e308a03
Show file tree
Hide file tree
Showing 43 changed files with 1,051 additions and 754 deletions.
Binary file modified cocli/cmd/testcases/psa-refval.cbor
Binary file not shown.
Binary file modified cocli/cmd/testcases/signed-corim-invalid.cbor
Binary file not shown.
Binary file modified cocli/cmd/testcases/signed-corim-valid-with-cots.cbor
Binary file not shown.
Binary file modified cocli/cmd/testcases/signed-corim-valid.cbor
Binary file not shown.
88 changes: 52 additions & 36 deletions cocli/cmd/testcases/src/psa-refval.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,55 @@
# acme-implementation-id-000000001
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:
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=
- 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 |-
YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDEK
# acme-implementation-id-000000001
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 |-
YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDEK
# acme-implementation-id-000000001
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=
84 changes: 48 additions & 36 deletions cocli/cmd/testcases/src/signed-corim-valid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,54 @@
value: acme-implementation-id-000000001
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:
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=
- 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: acme-implementation-id-000000001
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: acme-implementation-id-000000001
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=
2:
- 0:
tag: 32
Expand Down
88 changes: 52 additions & 36 deletions cocli/cmd/testcases/src/test-comid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,55 @@
# acme-implementation-id-000000001
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:
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=
- 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 |-
YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDEK
# acme-implementation-id-000000001
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 |-
YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDEK
# acme-implementation-id-000000001
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=
Binary file modified cocli/cmd/testcases/test-comid.cbor
Binary file not shown.
Binary file modified cocli/cmd/testcases/test-coswid.cbor
Binary file not shown.
Binary file modified cocli/cmd/testcases/test-cots.cbor
Binary file not shown.
18 changes: 8 additions & 10 deletions comid/comid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ func Test_Comid_ToJSONPretty(t *testing.T) {
Environment: Environment{
Instance: MustNewUUIDInstance(TestUUID),
},
Measurements: *NewMeasurements().Add(&Measurement{
Measurement: Measurement{
Val: Mval{
RawValue: NewRawValue().SetBytes(MustHexDecode(t, "deadbeef")),
},
}),
},
}),
}

Expand All @@ -70,16 +70,14 @@ func Test_Comid_ToJSONPretty(t *testing.T) {
"value": "31fb5abf-023e-4992-aa4e-95f9c1503bfa"
}
},
"measurements": [
{
"value": {
"raw-value": {
"type": "bytes",
"value": "3q2+7w=="
}
"measurement": {
"value": {
"raw-value": {
"type": "bytes",
"value": "3q2+7w=="
}
}
]
}
}
]
}
Expand Down
20 changes: 2 additions & 18 deletions comid/example_cca_realm_refval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,8 @@ func extractRealmRefVal(rv ValueTriple) error {
return fmt.Errorf("extracting realm instanceID: %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)
}
if err := extractMeasurement(rv.Measurement); err != nil {
return fmt.Errorf("extracting measurement: %w", err)
}

return nil
Expand Down
Loading

0 comments on commit e308a03

Please sign in to comment.