Skip to content

Commit c63d3e0

Browse files
authored
Fix up messages.cddl (#96)
messagers.cddl was inconsistend with the request type enum and was missing definitions of key type and certificate format values. This patch fixes the inconsistencies and uses groups and choices to more explicitely describe the message format.
1 parent 276fdeb commit c63d3e0

1 file changed

Lines changed: 58 additions & 25 deletions

File tree

src/service/messages.cddl

Lines changed: 58 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,26 @@
4545

4646
; Main request message structure
4747
request = [
48-
request_type: uint,
48+
request_type: request_type,
4949
payload: request_payload
5050
]
5151

52-
request_type = 0..4 ; promote=0, issue_cdi_cert=1, issue_eca_cert=2, issue_eca_ee_cert=3, eca_ee_sign=4
53-
54-
request_payload = promote_request /
55-
issue_cdi_cert_request /
56-
issue_eca_cert_request /
57-
issue_eca_ee_cert_request /
58-
eca_ee_sign_request
52+
; Requests
53+
request_types = (
54+
promote: 1,
55+
issue_cdi_cert: 2,
56+
issue_eca_cert: 3,
57+
issue_eca_ee_cert: 4,
58+
eca_ee_sign: 5
59+
)
60+
request_type = &request_types
61+
62+
request_payload =
63+
promote_request \
64+
issue_cdi_cert_request \
65+
issue_eca_cert_request \
66+
issue_eca_ee_cert_request \
67+
eca_ee_sign_request
5968

6069
; Labels for map keys
6170
issuer_key_type_label = 1
@@ -81,38 +90,38 @@ error_code_label = 20
8190
certificate_label = 21
8291
signature_label = 22
8392

84-
; Promote request (key 0)
93+
; Promote request (key 1)
8594
promote_request = {
8695
compressed_context_label: compressed_context_bytes, ; compressed_context
8796
* int => any ; extensible for unknown keys
8897
}
8998

9099
compressed_context_bytes = bstr
91100

92-
; Issue CDI certificate request (key 1)
101+
; Issue CDI certificate request (key 2)
93102
issue_cdi_cert_request = {
94-
issuer_key_type_label: issuer_key_type, ; issuer_key_type
95-
subject_key_type_label: subject_key_type, ; subject_key_type
103+
issuer_key_type_label: key_type, ; issuer_key_type
104+
subject_key_type_label: key_type, ; subject_key_type
96105
open_dice_input_label: open_dice_input, ; context
97106
? parent_path_label: compressed_context_array, ; parent_path (optional)
98107
certificate_format_label: certificate_format, ; certificate_format
99108
* int => any ; extensible for unknown keys
100109
}
101110

102-
; Issue ECA certificate request (key 2)
111+
; Issue ECA certificate request (key 3)
103112
issue_eca_cert_request = {
104-
issuer_key_type_label: issuer_key_type, ; issuer_key_type
105-
subject_key_type_label: subject_key_type, ; subject_key_type
113+
issuer_key_type_label: key_type, ; issuer_key_type
114+
subject_key_type_label: key_type, ; subject_key_type
106115
? parent_path_label: compressed_context_array, ; parent_path (optional)
107116
certificate_format_label: certificate_format, ; certificate_format
108117
? challenge_label: challenge_bytes, ; challenge (optional)
109118
* int => any ; extensible for unknown keys
110119
}
111120

112-
; Issue ECA End-Entity certificate request (key 3)
121+
; Issue ECA End-Entity certificate request (key 4)
113122
issue_eca_ee_cert_request = {
114-
issuer_key_type_label: issuer_key_type, ; issuer_key_type
115-
subject_key_type_label: subject_key_type, ; subject_key_type
123+
issuer_key_type_label: key_type, ; issuer_key_type
124+
subject_key_type_label: key_type, ; subject_key_type
116125
? parent_path_label: compressed_context_array, ; parent_path (optional)
117126
certificate_format_label: certificate_format, ; certificate_format
118127
? name_label: name_string, ; name (optional)
@@ -121,9 +130,9 @@ issue_eca_ee_cert_request = {
121130
* int => any ; extensible for unknown keys
122131
}
123132

124-
; ECA End-Entity sign request (key 4)
133+
; ECA End-Entity sign request (key 5)
125134
eca_ee_sign_request = {
126-
subject_key_type_label: subject_key_type, ; subject_key_type (no issuer_key_type for signing)
135+
subject_key_type_label: key_type, ; subject_key_type (no issuer_key_type for signing)
127136
? parent_path_label: compressed_context_array, ; parent_path (optional)
128137
name_label: name_string, ; name
129138
key_usage_label: key_usage_bytes, ; key_usage
@@ -139,18 +148,42 @@ open_dice_input = {
139148
? configuration_descriptor_label: configuration_descriptor_bytes, ; configuration_descriptor (optional)
140149
? authority_hash_label: authority_hash_bytes, ; authority_hash (optional)
141150
? authority_descriptor_label: authority_descriptor_bytes, ; authority_descriptor (optional)
142-
? mode_label: mode_uint, ; mode (optional, 0-3)
151+
? mode_label: mode, ; mode (optional, 0-3)
143152
? hidden_label: hidden_bytes, ; hidden (optional)
144153
? profile_name_label: profile_name_string, ; profile_name (optional)
145154
* int => any ; extensible for unknown keys
146155
}
147156

148157
; Common types
149158
compressed_context_array = [* compressed_context_bytes]
150-
issuer_key_type = uint ; crypto key type enum
151-
subject_key_type = uint ; crypto key type enum
152-
certificate_format = uint ; certificate format enum
153-
mode_uint = 0..3 ; not_configured=0, normal=1, debug=2, recovery=3
159+
160+
; Mode
161+
modes = (
162+
mode_not_configured: 0,
163+
mode_normal: 1,
164+
mode_debug: 2,
165+
mode_recovery: 3
166+
)
167+
mode = &modes
168+
169+
; Crypto key types
170+
; keep values in sync with enum n20_crypto_key_type_s
171+
; Note: Not all values (e.g. cdi) are part of the wire format.
172+
key_types = (
173+
key_type_none: 0,
174+
key_type_secp256r1: 1,
175+
key_type_secp384r1: 2,
176+
key_type_ed25519: 3
177+
)
178+
key_type = &key_types
179+
180+
; Certificate formats (keep in sync with enum n20_certificate_format_s)
181+
certificate_formats = (
182+
certificate_format_none: 0,
183+
certificate_format_x509: 1,
184+
certificate_format_cose: 2
185+
)
186+
certificate_format = &certificate_formats
154187

155188
; Data types
156189
code_hash_bytes = bstr

0 commit comments

Comments
 (0)