xref: /aosp_15_r20/external/pigweed/pw_software_update/update_bundle.proto (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker// Copyright 2021 The Pigweed Authors
2*61c4878aSAndroid Build Coastguard Worker//
3*61c4878aSAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4*61c4878aSAndroid Build Coastguard Worker// use this file except in compliance with the License. You may obtain a copy of
5*61c4878aSAndroid Build Coastguard Worker// the License at
6*61c4878aSAndroid Build Coastguard Worker//
7*61c4878aSAndroid Build Coastguard Worker//     https://www.apache.org/licenses/LICENSE-2.0
8*61c4878aSAndroid Build Coastguard Worker//
9*61c4878aSAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software
10*61c4878aSAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11*61c4878aSAndroid Build Coastguard Worker// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12*61c4878aSAndroid Build Coastguard Worker// License for the specific language governing permissions and limitations under
13*61c4878aSAndroid Build Coastguard Worker// the License.
14*61c4878aSAndroid Build Coastguard Worker
15*61c4878aSAndroid Build Coastguard Workersyntax = "proto3";
16*61c4878aSAndroid Build Coastguard Worker
17*61c4878aSAndroid Build Coastguard Workerpackage pw.software_update;
18*61c4878aSAndroid Build Coastguard Worker
19*61c4878aSAndroid Build Coastguard Workerimport "pw_software_update/tuf.proto";
20*61c4878aSAndroid Build Coastguard Worker
21*61c4878aSAndroid Build Coastguard Workeroption java_multiple_files = true;
22*61c4878aSAndroid Build Coastguard Workeroption java_package = "dev.pigweed.pw_software_update";
23*61c4878aSAndroid Build Coastguard Worker
24*61c4878aSAndroid Build Coastguard Workermessage UpdateBundle {
25*61c4878aSAndroid Build Coastguard Worker  // The timestamp role is used for freshness check of the snapshot. Any
26*61c4878aSAndroid Build Coastguard Worker  // project-specific update metadata should go in the top-level
27*61c4878aSAndroid Build Coastguard Worker  // targets_metadata or with the TargetFile information
28*61c4878aSAndroid Build Coastguard Worker  optional SignedTimestampMetadata timestamp_metadata = 1;
29*61c4878aSAndroid Build Coastguard Worker
30*61c4878aSAndroid Build Coastguard Worker  // The snapshot role is used to ensure that the collection of targets_metadata
31*61c4878aSAndroid Build Coastguard Worker  // files is securely consistent (no target metadata mix and match). Any
32*61c4878aSAndroid Build Coastguard Worker  // project-specific update metadata should go in the top-level
33*61c4878aSAndroid Build Coastguard Worker  // targets_metadata or with the TargetFile information
34*61c4878aSAndroid Build Coastguard Worker  optional SignedSnapshotMetadata snapshot_metadata = 2;
35*61c4878aSAndroid Build Coastguard Worker
36*61c4878aSAndroid Build Coastguard Worker  // Map of target metadata name to target metadata.
37*61c4878aSAndroid Build Coastguard Worker  // Target metadata name can be an arbitrary name or a path that describes
38*61c4878aSAndroid Build Coastguard Worker  // where the file lives relative to the base directory of the repository, as
39*61c4878aSAndroid Build Coastguard Worker  // described in the snapshot metadata. e.g. "path/to/target/0".
40*61c4878aSAndroid Build Coastguard Worker  map<string, SignedTargetsMetadata> targets_metadata = 3;
41*61c4878aSAndroid Build Coastguard Worker
42*61c4878aSAndroid Build Coastguard Worker  // Map of target file name to target payload bytes.
43*61c4878aSAndroid Build Coastguard Worker  // Target file name can be an arbitrary name or a path that describes where
44*61c4878aSAndroid Build Coastguard Worker  // the file lives relative to the base directory of the repository, as
45*61c4878aSAndroid Build Coastguard Worker  // described in the target metadata. e.g. "path/to/amber_tools/0".
46*61c4878aSAndroid Build Coastguard Worker  map<string, bytes> target_payloads = 4;
47*61c4878aSAndroid Build Coastguard Worker
48*61c4878aSAndroid Build Coastguard Worker  // If present, a client will attempt to upgrade its on-device trusted root
49*61c4878aSAndroid Build Coastguard Worker  // metadata to the root metadata included in the bundle, following the
50*61c4878aSAndroid Build Coastguard Worker  // standard "Update the root role" flow specified in the TUF spec, but
51*61c4878aSAndroid Build Coastguard Worker  // without "version climbing".
52*61c4878aSAndroid Build Coastguard Worker  //
53*61c4878aSAndroid Build Coastguard Worker  // The exact steps are:
54*61c4878aSAndroid Build Coastguard Worker  // 1. Check if there is a root metadata in the bundle.
55*61c4878aSAndroid Build Coastguard Worker  // 2. If the root metadata IS NOT included, assume on-device root metadata
56*61c4878aSAndroid Build Coastguard Worker  //    is up-to-date and continue with the rest of metadata verification.
57*61c4878aSAndroid Build Coastguard Worker  // 3. If the root metadata IS included, verify the new root metadata using
58*61c4878aSAndroid Build Coastguard Worker  //    the on-device root metadata.
59*61c4878aSAndroid Build Coastguard Worker  // 4. If the verification is successful, persist new root metadata and
60*61c4878aSAndroid Build Coastguard Worker  //    continue with the rest of metadata verification. Otherwise abort the
61*61c4878aSAndroid Build Coastguard Worker  //    update session.
62*61c4878aSAndroid Build Coastguard Worker  //
63*61c4878aSAndroid Build Coastguard Worker  // The key deviation from standard flow is the client assumes it can always
64*61c4878aSAndroid Build Coastguard Worker  // directly upgrade to the single new root metadata in the update bundle,
65*61c4878aSAndroid Build Coastguard Worker  // without any step-stone history root metadata. This works only because
66*61c4878aSAndroid Build Coastguard Worker  // we are not supporting (more than 1) root key rotations.
67*61c4878aSAndroid Build Coastguard Worker  optional SignedRootMetadata root_metadata = 5;
68*61c4878aSAndroid Build Coastguard Worker}
69*61c4878aSAndroid Build Coastguard Worker
70*61c4878aSAndroid Build Coastguard Worker// Update bundle metadata
71*61c4878aSAndroid Build Coastguard Worker// Designed to inform the update server what the device currently has in-place.
72*61c4878aSAndroid Build Coastguard Worker// Also used to persist the TUF metadata for use in the verification process.
73*61c4878aSAndroid Build Coastguard Worker// Stored manifest is only written/erased by the update service. In all other
74*61c4878aSAndroid Build Coastguard Worker// contexts the stored manifest is considered read-only.
75*61c4878aSAndroid Build Coastguard Workermessage Manifest {
76*61c4878aSAndroid Build Coastguard Worker  map<string, TargetsMetadata> targets_metadata = 1;
77*61c4878aSAndroid Build Coastguard Worker
78*61c4878aSAndroid Build Coastguard Worker  // Insert user manifest target file content here
79*61c4878aSAndroid Build Coastguard Worker  optional bytes user_manifest = 2;
80*61c4878aSAndroid Build Coastguard Worker}
81