Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: delta_performer.h

Issue 3547019: AU: DeltaPerformer performs the download size/hash check now. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | delta_performer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__ 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__ 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__
7 7
8 #include <inttypes.h> 8 #include <inttypes.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 11 matching lines...) Expand all
22 // This class performs the actions in a delta update synchronously. The delta 22 // This class performs the actions in a delta update synchronously. The delta
23 // update itself should be passed in in chunks as it is received. 23 // update itself should be passed in in chunks as it is received.
24 24
25 class DeltaPerformer : public FileWriter { 25 class DeltaPerformer : public FileWriter {
26 public: 26 public:
27 DeltaPerformer(PrefsInterface* prefs) 27 DeltaPerformer(PrefsInterface* prefs)
28 : prefs_(prefs), 28 : prefs_(prefs),
29 fd_(-1), 29 fd_(-1),
30 kernel_fd_(-1), 30 kernel_fd_(-1),
31 manifest_valid_(false), 31 manifest_valid_(false),
32 manifest_metadata_size_(0),
32 next_operation_num_(0), 33 next_operation_num_(0),
33 buffer_offset_(0), 34 buffer_offset_(0),
34 last_updated_buffer_offset_(kuint64max), 35 last_updated_buffer_offset_(kuint64max),
35 block_size_(0) {} 36 block_size_(0) {}
36 37
37 // Opens the kernel. Should be called before or after Open(), but before 38 // Opens the kernel. Should be called before or after Open(), but before
38 // Write(). The kernel file will be close()d when Close() is called. 39 // Write(). The kernel file will be close()d when Close() is called.
39 bool OpenKernel(const char* kernel_path); 40 bool OpenKernel(const char* kernel_path);
40 41
41 // flags and mode ignored. Once Close()d, a DeltaPerformer can't be 42 // flags and mode ignored. Once Close()d, a DeltaPerformer can't be
42 // Open()ed again. 43 // Open()ed again.
43 int Open(const char* path, int flags, mode_t mode); 44 int Open(const char* path, int flags, mode_t mode);
44 45
45 // Wrapper around write. Returns bytes written on success or 46 // Wrapper around write. Returns bytes written on success or
46 // -errno on error. 47 // -errno on error.
47 ssize_t Write(const void* bytes, size_t count); 48 ssize_t Write(const void* bytes, size_t count);
48 49
49 // Wrapper around close. Returns 0 on success or -errno on error. 50 // Wrapper around close. Returns 0 on success or -errno on error.
50 // Closes both 'path' given to Open() and the kernel path. 51 // Closes both 'path' given to Open() and the kernel path.
51 int Close(); 52 int Close();
52 53
53 // Verifies the downloaded payload against the signed hash included in the 54 // Verifies the downloaded payload against the signed hash included in the
54 // payload and returns true on success, false on failure. This method should 55 // payload as well as against the update check hash and size and returns true
55 // be called after closing the stream. Note this method returns true if the 56 // on success, false on failure. This method should be called after closing
56 // public key is unavailable; it returns false if the public key is available 57 // the stream. Note this method skips the signed hash check if the public key
57 // but the delta payload doesn't include a signature. If |public_key_path| is 58 // is unavailable; it returns false if the public key is available but the
58 // an empty string, uses the default public key path. 59 // delta payload doesn't include a signature. If |public_key_path| is an empty
59 bool VerifyPayload(const std::string& public_key_path); 60 // string, uses the default public key path.
61 bool VerifyPayload(const std::string& public_key_path,
62 const std::string& update_check_response_hash,
63 const uint64_t update_check_response_size);
60 64
61 // Converts an ordered collection of Extent objects which contain data of 65 // Converts an ordered collection of Extent objects which contain data of
62 // length full_length to a comma-separated string. For each Extent, the 66 // length full_length to a comma-separated string. For each Extent, the
63 // string will have the start offset and then the length in bytes. 67 // string will have the start offset and then the length in bytes.
64 // The length value of the last extent in the string may be short, since 68 // The length value of the last extent in the string may be short, since
65 // the full length of all extents in the string is capped to full_length. 69 // the full length of all extents in the string is capped to full_length.
66 // Also, an extent starting at kSparseHole, appears as -1 in the string. 70 // Also, an extent starting at kSparseHole, appears as -1 in the string.
67 // For example, if the Extents are {1, 1}, {4, 2}, {kSparseHole, 1}, 71 // For example, if the Extents are {1, 1}, {4, 2}, {kSparseHole, 1},
68 // {0, 1}, block_size is 4096, and full_length is 5 * block_size - 13, 72 // {0, 1}, block_size is 4096, and full_length is 5 * block_size - 13,
69 // the resulting string will be: "4096:4096,16384:8192,-1:4096,0:4083" 73 // the resulting string will be: "4096:4096,16384:8192,-1:4096,0:4083"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 bool is_kernel_partition); 105 bool is_kernel_partition);
102 bool PerformBsdiffOperation( 106 bool PerformBsdiffOperation(
103 const DeltaArchiveManifest_InstallOperation& operation, 107 const DeltaArchiveManifest_InstallOperation& operation,
104 bool is_kernel_partition); 108 bool is_kernel_partition);
105 109
106 // Returns true if the payload signature message has been extracted from 110 // Returns true if the payload signature message has been extracted from
107 // |operation|, false otherwise. 111 // |operation|, false otherwise.
108 bool ExtractSignatureMessage( 112 bool ExtractSignatureMessage(
109 const DeltaArchiveManifest_InstallOperation& operation); 113 const DeltaArchiveManifest_InstallOperation& operation);
110 114
111 // Discard |count| bytes from the beginning of buffer_. If |do_hash| is true, 115 // Updates the hash calculator with |count| bytes at the head of |buffer_| and
112 // updates the hash calculator with these bytes before discarding them. 116 // then discards them.
113 void DiscardBufferHeadBytes(size_t count, bool do_hash); 117 void DiscardBufferHeadBytes(size_t count);
114 118
115 // Checkpoints the update progress into persistent storage to allow this 119 // Checkpoints the update progress into persistent storage to allow this
116 // update attempt to be resumed after reboot. 120 // update attempt to be resumed after reboot.
117 bool CheckpointUpdateProgress(); 121 bool CheckpointUpdateProgress();
118 122
119 // Update Engine preference store. 123 // Update Engine preference store.
120 PrefsInterface* prefs_; 124 PrefsInterface* prefs_;
121 125
122 // File descriptor of open device. 126 // File descriptor of open device.
123 int fd_; 127 int fd_;
124 128
125 // File descriptor of the kernel device 129 // File descriptor of the kernel device
126 int kernel_fd_; 130 int kernel_fd_;
127 131
128 std::string path_; // Path that fd_ refers to. 132 std::string path_; // Path that fd_ refers to.
129 std::string kernel_path_; // Path that kernel_fd_ refers to. 133 std::string kernel_path_; // Path that kernel_fd_ refers to.
130 134
131 DeltaArchiveManifest manifest_; 135 DeltaArchiveManifest manifest_;
132 bool manifest_valid_; 136 bool manifest_valid_;
137 uint64_t manifest_metadata_size_;
133 138
134 // Index of the next operation to perform in the manifest. 139 // Index of the next operation to perform in the manifest.
135 int next_operation_num_; 140 int next_operation_num_;
136 141
137 // buffer_ is a window of the data that's been downloaded. At first, 142 // buffer_ is a window of the data that's been downloaded. At first,
138 // it contains the beginning of the download, but after the protobuf 143 // it contains the beginning of the download, but after the protobuf
139 // has been downloaded and parsed, it contains a sliding window of 144 // has been downloaded and parsed, it contains a sliding window of
140 // data blobs. 145 // data blobs.
141 std::vector<char> buffer_; 146 std::vector<char> buffer_;
142 // Offset of buffer_ in the binary blobs section of the update. 147 // Offset of buffer_ in the binary blobs section of the update.
143 uint64_t buffer_offset_; 148 uint64_t buffer_offset_;
144 149
145 // Last |buffer_offset_| value updated as part of the progress update. 150 // Last |buffer_offset_| value updated as part of the progress update.
146 uint64_t last_updated_buffer_offset_; 151 uint64_t last_updated_buffer_offset_;
147 152
148 // The block size (parsed from the manifest). 153 // The block size (parsed from the manifest).
149 uint32_t block_size_; 154 uint32_t block_size_;
150 155
151 // Calculate the payload hash to verify against the signed hash. 156 // Calculates the payload hash.
152 OmahaHashCalculator hash_calculator_; 157 OmahaHashCalculator hash_calculator_;
153 158
159 // Saves the signed hash context.
160 std::string signed_hash_context_;
161
154 // Signatures message blob extracted directly from the payload. 162 // Signatures message blob extracted directly from the payload.
155 std::vector<char> signatures_message_data_; 163 std::vector<char> signatures_message_data_;
156 164
157 DISALLOW_COPY_AND_ASSIGN(DeltaPerformer); 165 DISALLOW_COPY_AND_ASSIGN(DeltaPerformer);
158 }; 166 };
159 167
160 } // namespace chromeos_update_engine 168 } // namespace chromeos_update_engine
161 169
162 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__ 170 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__
OLDNEW
« no previous file with comments | « no previous file | delta_performer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698