|
3 | 3 | SHELL := /bin/bash |
4 | 4 |
|
5 | 5 | include tools.mk |
6 | | - |
7 | | -%.cbor: %.diag |
8 | | - $(diag2cbor) $< > $@ |
| 6 | +include check.mk |
| 7 | +include corim-frags.mk |
9 | 8 |
|
10 | 9 | check:: cbor-tags-unique |
11 | 10 | check:: check-intrep check-intrep-examples |
12 | 11 | check:: check-corim check-corim-examples |
13 | 12 | check:: check-comid check-comid-examples |
14 | 13 | check:: check-cotl check-cotl-examples |
15 | 14 |
|
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 |
76 | 16 |
|
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))) |
78 | 21 |
|
79 | 22 | clean: ; rm -f $(CLEANFILES) |
80 | 23 |
|
|
0 commit comments