Skip to content

Commit

Permalink
Create signed example in Makefile.
Browse files Browse the repository at this point in the history
  • Loading branch information
deeglaze committed Dec 18, 2024
1 parent d401fbf commit ae65445
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cddl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ CLEANFILES += $(3:.diag=.pretty)

endef # cddl_check_template

examples/sig-structure.diag: examples/sig-structure.diag.tmpl examples/payload-corim-4.diag examples/protected-header-map.diag
payload="$$(cat examples/payload-corim-4.diag)" \
protected="$$(cat examples/protected-header-map.diag)" \
envsubst < examples/sig-structure.diag.tmpl > examples/sig-structure.diag

examples/testkey.pem:
openssl ecparam -name secp384r1 -genkey -noout -out examples/testkey.pem

examples/corim-4.sig: examples/sig-structure.cbor examples/testkey.pem
openssl dgst -sha384 -sign examples/testkey.pem -out examples/corim-4.sig examples/sig-structure.cbor

examples/corim-4.diag: examples/corim-4.sig examples/corim-4.diag.tmpl examples/payload-corim-4.diag examples/protected-header-map.diag
payload="$$(cat examples/payload-corim-4.diag)" \
protected="$$(cat examples/protected-header-map.diag)" \
signature="h'$$(cat examples/corim-4.sig | xxd -p -c 128)'" \
envsubst < examples/corim-4.diag.tmpl > examples/corim-4.diag

include corim-frags.mk

$(eval $(call cddl_check_template,comid,$(COMID_FRAGS),$(COMID_EXAMPLES)))
Expand Down
1 change: 1 addition & 0 deletions cddl/cbor-tags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ tagged-cert-thumbprint-type = #6.559(digest)
tagged-bytes = #6.560(bytes)
tagged-cert-path-thumbprint-type = #6.561(digest)
tagged-pkix-asn1der-cert-type = #6.562(bstr)
tagged-integral-predicate= #6.563(integral-predicate)
60 changes: 60 additions & 0 deletions cddl/examples/corim-4.diag
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/ signed-corim / 18([
/ protected / << / header_map / {
/ alg: / 1 : -35,
/ content-type: / 3 : "application/rim+cbor",
/ corim-meta: / 8 : << / corim-meta / {
/ signer: / 0 : / corim-signer-map / {
/ signer: / 0 : "ACME Ltd."
}
} >>,
/ kid: / 4 : h'f8ccd2b49fdba32cd94498030fdc8e5010358919'
} >>,
/ unprotected-corim-header-map / {},
/ payload / << 501(/ corim-map / {
/ corim.id / 0 : h'284e6c3e5d9f4f6b851f5a4247f243a7',
/ corim.tags / 1 : [
/ concise-mid-tag / 506( <<
/ 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 / {
/ 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'
] ]
}
}
]
] ]
}
}
>> )
]
}) >>,
/ signature / h'30660231008520f6f6980ee6e702602450fba17ee151c479dc85cc8e55ecc31afe28eb4c50d8fd98230eef1bfc9d631a23a0bc76850231009df2d8656978d590aabefac29ebeedea18adc9de837ddf59b5d4348bd6ab15cef526de0b20c32db6b9fd8b7b49cd5b20'
])
6 changes: 6 additions & 0 deletions cddl/examples/corim-4.diag.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/ signed-corim / 18([
/ protected / << ${protected} >>,
/ unprotected-corim-header-map / {},
/ payload / << ${payload} >>,
/ signature / ${signature}
])
46 changes: 46 additions & 0 deletions cddl/examples/payload-corim-4.diag
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
501(/ corim-map / {
/ corim.id / 0 : h'284e6c3e5d9f4f6b851f5a4247f243a7',
/ corim.tags / 1 : [
/ concise-mid-tag / 506( <<
/ 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 / {
/ 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'
] ]
}
}
]
] ]
}
}
>> )
]
})
10 changes: 10 additions & 0 deletions cddl/examples/protected-header-map.diag
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/ header_map / {
/ alg: / 1 : -35,
/ content-type: / 3 : "application/rim+cbor",
/ corim-meta: / 8 : << / corim-meta / {
/ signer: / 0 : / corim-signer-map / {
/ signer: / 0 : "ACME Ltd."
}
} >>,
/ kid: / 4 : h'f8ccd2b49fdba32cd94498030fdc8e5010358919'
}
6 changes: 6 additions & 0 deletions cddl/examples/sig-structure.diag.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/ Sig_structure / [
/ context: / "Signature1",
/ body_protected: / << ${protected} >>,
/ external_aad: / h'',
/ payload: / << ${payload} >>
]

0 comments on commit ae65445

Please sign in to comment.