Skip to content

Commit 80fd3e3

Browse files
Merge branch 'main' into pr502-dmt-prose
2 parents 45bb226 + 4f1a5ef commit 80fd3e3

19 files changed

+243
-154
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ gem 'cddl', '>=0.12.6'
55
gem 'cbor-diag', '>=0.8.7'
66
gem 'base64'
77
gem 'pstore'
8+
gem 'cddlc', '>=0.3.4'

cddl/Makefile

Lines changed: 7 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3,78 +3,21 @@
33
SHELL := /bin/bash
44

55
include tools.mk
6-
7-
%.cbor: %.diag
8-
$(diag2cbor) $< > $@
6+
include check.mk
7+
include corim-frags.mk
98

109
check:: cbor-tags-unique
1110
check:: check-intrep check-intrep-examples
1211
check:: check-corim check-corim-examples
1312
check:: check-comid check-comid-examples
1413
check:: check-cotl check-cotl-examples
1514

16-
# $1: label
17-
# $2: cddl fragments
18-
# $3: diag test files
19-
define cddl_check_template
20-
21-
check-$(1): $(1)-autogen.cddl
22-
$$(cddl) $$< g 1 | $$(diag2diag) -e
23-
24-
.PHONY: check-$(1)
25-
26-
$(1)-autogen.cddl: $(2)
27-
for f in $$^ ; do ( grep -v '^;' $$$$f ; echo ) ; done > $$@
28-
29-
CLEANFILES += $(1)-autogen.cddl
30-
31-
check-$(1)-examples: $(1)-autogen.cddl $(3:.diag=.cbor)
32-
@for f in $(3:.diag=.cbor); do \
33-
echo ">> validating $$$$f against $$<" ; \
34-
$$(cddl) $$< validate $$$$f &>/dev/null || exit 1 ; \
35-
echo ">> saving prettified CBOR to $$$${f%.cbor}.pretty" ; \
36-
$$(cbor2pretty) $$$$f > $$$${f%.cbor}.pretty ; \
37-
done
38-
39-
.PHONY: check-$(1)-examples
40-
41-
CLEANFILES += $(3:.diag=.cbor)
42-
CLEANFILES += $(3:.diag=.pretty)
43-
44-
endef # cddl_check_template
45-
46-
# Commented since CI doesn't have openssl
47-
examples/sig-structure.diag: examples/sig-structure.diag.tmpl examples/payload-corim-4.diag examples/protected-header-map-corim-meta.diag
48-
payload="$$(cat examples/payload-corim-4.diag)" \
49-
protected="$$(cat examples/protected-header-map-corim-meta.diag)" \
50-
envsubst < examples/sig-structure.diag.tmpl > examples/sig-structure.diag
51-
52-
examples/testkey.pem:
53-
openssl ecparam -name secp384r1 -genkey -noout -out examples/testkey.pem
54-
55-
examples/corim-4.sig: examples/sig-structure.cbor examples/testkey.pem
56-
openssl dgst -sha384 -sign examples/testkey.pem -out examples/corim-4.sig examples/sig-structure.cbor
57-
58-
examples/corim-4.diag: examples/corim-4.sig examples/corim-4.diag.tmpl examples/payload-corim-4.diag examples/protected-header-map-corim-meta.diag
59-
payload="$$(cat examples/payload-corim-4.diag)" \
60-
protected="$$(cat examples/protected-header-map-corim-meta.diag)" \
61-
signature="h'$$(cat examples/corim-4.sig | xxd -p -c 128)'" \
62-
envsubst < examples/corim-4.diag.tmpl > examples/corim-4.diag
63-
64-
include corim-frags.mk
65-
66-
$(eval $(call cddl_check_template,comid,$(COMID_FRAGS),$(COMID_EXAMPLES)))
67-
$(eval $(call cddl_check_template,cotl,$(COTL_FRAGS),$(COTL_EXAMPLES)))
68-
$(eval $(call cddl_check_template,corim,$(CORIM_FRAGS),$(CORIM_EXAMPLES)))
69-
$(eval $(call cddl_check_template,intrep,$(INTREP_FRAGS),$(INTREP_EXAMPLES)))
70-
71-
GITHUB := https://raw.githubusercontent.com/
72-
COSWID_REPO := sacmwg/draft-ietf-sacm-coswid/master
73-
COSWID_REPO_URL := $(join $(GITHUB), $(COSWID_REPO))
74-
75-
concise-swid-tag.cddl: ; $(curl) -O $(COSWID_REPO_URL)/$@
15+
include measured-component.mk
7616

77-
CLEANFILES += concise-swid-tag.cddl
17+
$(eval $(call cddl_check_template,comid,$(COMID_FRAGS),$(COMID_EXAMPLES),$(COMID_IMPORTS)))
18+
$(eval $(call cddl_check_template,cotl,$(COTL_FRAGS),$(COTL_EXAMPLES),$(COTL_IMPORTS)))
19+
$(eval $(call cddl_check_template,corim,$(CORIM_FRAGS),$(CORIM_EXAMPLES),$(CORIM_IMPORTS)))
20+
$(eval $(call cddl_check_template,intrep,$(INTREP_FRAGS),$(INTREP_EXAMPLES),$(INTREP_IMPORTS)))
7821

7922
clean: ; rm -f $(CLEANFILES)
8023

cddl/cbor-tags.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tagged-unsigned-corim-map = #6.501(unsigned-corim-map)
2-
tagged-concise-swid-tag = #6.505(bytes .cbor concise-swid-tag)
2+
tagged-concise-swid-tag = #6.505(bytes .cbor coswid.concise-swid-tag)
33
tagged-concise-mid-tag = #6.506(bytes .cbor concise-mid-tag)
44
tagged-concise-tl-tag = #6.508(bytes .cbor concise-tl-tag)
55
tagged-ueid-type = #6.550(ueid-type)
@@ -8,11 +8,11 @@ tagged-min-svn = #6.553(min-svn)
88
tagged-pkix-base64-key-type = #6.554(tstr)
99
tagged-pkix-base64-cert-type = #6.555(tstr)
1010
tagged-pkix-base64-cert-path-type = #6.556(tstr)
11-
tagged-key-thumbprint-type = #6.557(digest)
11+
tagged-key-thumbprint-type = #6.557(eatmc.digest)
1212
tagged-cose-key-type = #6.558(COSE_Key)
13-
tagged-cert-thumbprint-type = #6.559(digest)
13+
tagged-cert-thumbprint-type = #6.559(eatmc.digest)
1414
tagged-bytes = #6.560(bytes)
15-
tagged-cert-path-thumbprint-type = #6.561(digest)
15+
tagged-cert-path-thumbprint-type = #6.561(eatmc.digest)
1616
tagged-pkix-asn1der-cert-type = #6.562(bstr)
1717
tagged-masked-raw-value = #6.563([
1818
tagged-int-range = #6.564(int-range)

cddl/check.mk

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
%.cbor: %.diag ; $(diag2cbor) $< > $@
2+
3+
# $1: label
4+
# $2: cddl fragments
5+
# $3: diag or json test files
6+
# $4: imports (namespace=basename ...)
7+
define cddl_check_template
8+
9+
check-$(1): $(1)-autogen.cddl
10+
$$(cddl) $$< g 1 | $$(diag2diag) -e
11+
12+
.PHONY: check-$(1)
13+
14+
$(1)-autogen.cddl: $(2) $(foreach i,$(4),$(lastword $(subst =, ,$(i)).cddl))
15+
$$(cddlc) $(foreach i,$(4),-I $(i)) -t cddl -2 $(2) > $$@
16+
17+
CLEANFILES += $(1)-autogen.cddl
18+
19+
check-$(1)-examples: $(1)-autogen.cddl $(3:.diag=.cbor)
20+
@for f in $(3:.diag=.cbor); do \
21+
echo ">> validating $$$$f against $$<" ; \
22+
$$(cddl) $$< validate $$$$f &>/dev/null || exit 1 ; \
23+
done
24+
25+
.PHONY: check-$(1)-examples
26+
27+
# Only clean up the example CBOR files generated from the EDN files; leave the
28+
# JSON files alone.
29+
CLEANFILES += $(patsubst %.diag,%.cbor,$(filter %.diag,$(3)))
30+
31+
endef # cddl_check_template
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
conditional-endorsement-series-triple-record = [
2-
condition: stateful-environment-record
2+
condition: [
3+
environment: environment-map
4+
claims-list: [ * measurement-map ]
5+
? authorized-by: [ + $crypto-key-type-choice ]
6+
]
37
series: [ + conditional-series-record ]
48
]

cddl/corim-frags.mk

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ COMID_FRAGS += uuid.cddl
4747
COMID_FRAGS += version-map.cddl
4848
COMID_FRAGS += digest.cddl
4949
COMID_FRAGS += integrity-registers.cddl
50-
COMID_FRAGS += concise-swid-tag.cddl
50+
51+
COMID_IMPORTS += eatmc=measured-component
5152

5253
COMID_EXAMPLES := $(wildcard examples/comid-*.diag)
5354

@@ -58,7 +59,8 @@ COTL_FRAGS += tag-id-type-choice.cddl
5859
COTL_FRAGS += tag-identity-map.cddl
5960
COTL_FRAGS += uuid.cddl
6061
COTL_FRAGS += tag-version-type.cddl
61-
COTL_FRAGS += concise-swid-tag.cddl
62+
63+
COTL_IMPORTS += eatmc=measured-component
6264

6365
COTL_EXAMPLES := $(wildcard examples/cotl-*.diag)
6466

@@ -78,6 +80,9 @@ CORIM_FRAGS += cwt-claims.cddl
7880
CORIM_FRAGS += protected-corim-header-map.cddl
7981
CORIM_FRAGS += signed-corim.cddl
8082
CORIM_FRAGS += tagged-concise-swid-tag.cddl
83+
84+
CORIM_IMPORTS += eatmc=measured-component
85+
8186
CORIM_FRAGS += tagged-concise-mid-tag.cddl
8287
CORIM_FRAGS += tagged-concise-tl-tag.cddl
8388
CORIM_FRAGS += tagged-unsigned-corim-map.cddl
@@ -125,4 +130,6 @@ INTREP_FRAGS += cose-label-and-value.cddl
125130
INTREP_FRAGS += class-id-type-choice.cddl
126131
INTREP_FRAGS += oid.cddl
127132

133+
INTREP_IMPORTS += eatmc=measured-component
134+
128135
INTREP_EXAMPLES := $(wildcard examples/intrep-*.diag)

cddl/corim-locator-map.cddl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
;# import measured-component as eatmc
2+
13
corim-locator-map = {
24
&(href: 0) => uri / [ + uri ]
3-
? &(thumbprint: 1) => digest / [digest]
5+
? &(thumbprint: 1) => eatmc.digest / [ eatmc.digest ]
46
}

cddl/cose-sign1-corim.cddl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ COSE-Sign1-corim = [
55
signature: bstr
66
]
77

8-
hash-envelope-digest = bstr
8+
hash-envelope-digest = bstr
9+

cddl/coswid-triple-record.cddl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
;# import rfc9393 as coswid
2+
13
coswid-triple-record = [
24
environment-map
3-
[ + concise-swid-tag-id ]
5+
[ + coswid.tag-id ]
46
]
5-
6-
concise-swid-tag-id = text / bstr .size 16

cddl/crypto-key-type-choice.cddl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
;# import measured-component as eatmc
2+
13
$crypto-key-type-choice /= tagged-pkix-base64-key-type
24
$crypto-key-type-choice /= tagged-pkix-base64-cert-type
35
$crypto-key-type-choice /= tagged-pkix-base64-cert-path-type
@@ -10,8 +12,8 @@ $crypto-key-type-choice /= tagged-bytes
1012
tagged-pkix-base64-key-type = #6.554(tstr)
1113
tagged-pkix-base64-cert-type = #6.555(tstr)
1214
tagged-pkix-base64-cert-path-type = #6.556(tstr)
13-
tagged-key-thumbprint-type = #6.557(digest)
15+
tagged-key-thumbprint-type = #6.557(eatmc.digest)
1416
tagged-cose-key-type = #6.558(COSE_Key)
15-
tagged-cert-thumbprint-type = #6.559(digest)
16-
tagged-cert-path-thumbprint-type = #6.561(digest)
17+
tagged-cert-thumbprint-type = #6.559(eatmc.digest)
18+
tagged-cert-path-thumbprint-type = #6.561(eatmc.digest)
1719
tagged-pkix-asn1der-cert-type = #6.562(bstr)

0 commit comments

Comments
 (0)