1;
2; From https://datatracker.ietf.org/doc/draft-moran-suit-manifest/03/
3;
4; Copyright (c) 2018 IETF Trust and the persons identified as the
5; document authors.  All rights reserved.
6;
7; Redistribution and use in source and binary forms, with or without
8; modification, is permitted pursuant to, and subject to the license terms
9; contained in, the Simplified BSD License set forth in Section 4.c of the
10; IETF Trust’s Legal Provisions Relating to IETF Documents
11; (http://trustee.ietf.org/license-info).
12;
13
14OuterWrapper = {
15      authenticationWrapper: AuthenticationWrapper / nil,
16      manifest:              bstr .cbor Manifest,
17      ? preInstallExt:       bstr .cbor PreInstallationInfo,
18      ? installExt:          bstr .cbor InstallationInfo,
19      ? postInstallExt:      bstr .cbor PostInstallationInfo,
20      ? textExt:             bstr .cborseq Text,
21      ? coswidExt:           bstr .cbor concise-software-identity
22  }
23  authenticationWrapper = 1
24  manifest = 2
25  preInstallExt = 3
26  installExt = 4
27  postInstallExt = 5
28  textExt = 6
29  coswidExt = 7
30
31  AuthenticationWrapper = COSE_Sig
32
33  TextInfo = int
34
35  concise-software-identity = int
36
37  COSE_Mac0 = [
38        Headers,
39        payload : bstr / nil,
40        tag : bstr,
41     ]
42
43  Headers = (
44      protected : empty_or_serialized_map,
45      unprotected : {
46          ? kid: 4 => bstr
47      }
48  )
49
50  label = int
51  values = int
52
53  label_value = label => values
54
55  header_map = {
56      Generic_Headers,
57      * label_value
58  }
59
60  COSE_Sig0 = [
61        Headers,
62        signature : bstr,
63     ]
64  COSE_Sig = [
65        Headers,
66        payload : bstr / nil,
67        signatures : [+COSE_Sig0],
68     ]
69  COSE_Signature = int
70  COSE_Encrypt = int
71  COSE_Encrypt0 = int
72
73  empty_or_serialized_map = (bstr .cbor header_map) / (bstr .size 0)
74
75  Generic_Headers = (
76     ? algorithm_identifier: 1 => int / tstr,
77     ? criticality: 2 => [+label],
78     ? content_type: 3 => tstr / int,
79     ? key_identifier: 4 => bstr,
80     ? IV: 5 => bstr,
81     ? Partial_IV: 6 => bstr,
82     ? counter_signature: 7 => COSE_Signature / [+COSE_Signature]
83  )
84  COSE_Digest = COSE_Mac0
85
86  Manifest = {
87      manifestVersion : 1,
88      sequence        : SequenceNumber,
89      ? preInstall    : PreInstallationInfo / COSE_Digest,
90      ? dependencies  : [* DependencyInfo],
91      ? payloads      : [* PayloadInfo],
92      ? install       : InstallationInfo / COSE_Digest,
93      ? postInstall   : PostInstallationInfo / COSE_Digest,
94      ? text          : TextInfo / COSE_Digest,
95      ? coswid        : concise-software-identity / COSE_Digest
96  }
97
98  manifestVersion = 1
99  sequence        = 2
100  preInstall      = 3
101  dependencies    = 4
102  payloads        = 5
103  install         = 6
104  postInstall     = 7
105  text            = 8
106  coswid          = 9
107
108  SequenceNumber = uint
109
110  DependencyInfo = {
111      depDigest  : COSE_Digest,         ; digest of the resource
112      depScope   : ComponentIdentifier, ; where the dependency's
113                                        ; payloads will be applied
114      ? depUris  : UriList              ; where to find the resource
115                                       ; applied
116  }
117  depDigest = 1
118  depScope  = 2
119  depUris   = 3
120
121  PrioritizedUri = (priority: int, uri: tstr)
122  UriList = [ + PrioritizedUri ]
123  ComponentIdentifier = [* bstr]
124
125  PayloadInfo = {
126      payloadComponent:       ComponentIdentifier,
127      payloadSize:            (uint / nil),
128      payloadDigest:          COSE_Digest,
129      ? regenInfo : {
130          regenDigest:        COSE_Digest,
131          regenType:          int,
132          ? regenParameters:  bstr,
133      },
134  }
135  payloadComponent = 1
136  payloadSize      = 2
137  payloadDigest    = 3
138  regenInfo        = 4
139  regenDigest      = 5
140  regenType        = 6
141  regenParameters  = 7
142
143  RegenType = LocationLengthRegenType /
144              FileListRegenType /
145              KeyListRegenType /
146              CustomRegenType
147
148  LocationLengthRegenType = 1
149  FileListRegenType       = 2
150  KeyListRegenType        = 3
151  CustomRegenType         = nint
152
153  RegenParameters = LocationLengthRegenParameters /
154                    FileListRegenParameters /
155                    KeyListRegenParameters /
156                    CustomRegenParameters
157  LocationLength = [ location: uint, length: uint ]
158  LocationLengthRegenParameters = [ * LocationLength ]
159  FileListRegenParameters       = [ * file: tstr ]
160  KeyListRegenParameters        = [ * key: tstr ]
161  CustomRegenParameters         = bstr
162
163  PreInstallationInfo = {
164      ? preConditions : [ * PreCondition ],
165      ? preDirectives : [ * PreDirective ]
166  }
167  preConditions = 1
168  preDirectives = 2
169
170  PreCondition    = IdCondition /
171                    TimeCondition /
172                    ImageCondition /
173                    BatteryLevelCondition /
174                    CustomCondition
175
176  IdCondition     = [ vendor : 1, id: Uuid ] /
177                    [ class  : 2, id: Uuid ] /
178                    [ device : 3, id: Uuid ]
179  Uuid = bstr .size 16
180
181  TimeCondition   = [useBy: 4,
182                     time:       Timestamp]
183  ImageCondition  = [ currentContent : 6 ,
184                     digest: COSE_Digest / nil,
185                     location: ComponentIdentifier ] /
186                    [ notCurrentContent : 7 ,
187                     digest: COSE_Digest / nil,
188                     location: ComponentIdentifier ]
189  BatteryLevelCondition = [ batteryLevel: 8,
190                            level: uint ]
191  CustomCondition = [nint,
192                     customParameters: bstr]
193
194  Timestamp       = uint
195
196  PreDirective = WaitUntilDirective /
197                 DayOfWeekDirective /
198                 TimeOfDayDirective /
199                 BatteryLevelDirective /
200                 ExternalPowerDirective /
201                 CustomDirective
202
203  WaitUntilDirective     = [ 1,
204                             timestamp: uint ]
205  DayOfWeekDirective     = [ 2, day: 0..6 ]
206  TimeOfDayDirective     = [ 3, hours: 0..23,
207                                ? minutes: 0..59,
208                                ? seconds: 0..59 ]
209  BatteryLevelDirective  = [ 4, level: uint]
210  ExternalPowerDirective = [ 5 ]
211  NetworkDisconnectDirective = [ 6 ]
212  CustomDirective        = [ nint,
213                             ? customParameters: bstr ]
214
215  InstallationInfo = {
216     payloadInstallationInfo : [ * PayloadInstallationInfo ],
217  }
218  payloadInstallationInfo = 1
219
220  PayloadInstallationInfo = {
221     installComponent :          ComponentIdentifier,
222     payloadProcessors :         [ * Processor ],
223     ? allowOverride :           bool,
224     ? payloadInstaller:  {
225         payloadInstallerID:           [ * int ],
226         ? payloadInstallerParameters: bstr,
227     }
228  }
229  installComponent = 1
230  payloadProcessors = 2
231  allowOverride = 3
232  payloadInstaller = 4
233  payloadInstallerID = 5
234  payloadInstallerParameters = 6
235
236  Processor       = {
237      processorID:       ProcessorID,
238      ?parameters:        COSE_Digest / COSE_Encrypt / COSE_Encrypt0 /
239                         int / tstr / bstr / nil,
240      inputs:            UriList / ComponentIdentifier / {int => int},
241  }
242  processorID = 1
243  parameters  = 2
244  inputs      = 3
245
246  ProcessorID = [ * int ]
247
248  PostInstallationInfo = {
249      ? postConditions : [ * PostCondition ],
250      ? postDirectives : [ * PostDirective ]
251  }
252  postConditions = 1
253  postDirectives = 2
254
255  PostCondition   = ImageCondition / CustomCondition
256  PostDirective   = CustomDirective
257
258  Text = {
259      * int => tstr
260  }
261