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

Side by Side Diff: delta_performer.h

Issue 5516009: AU: Split applied update verification into a separate step. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git@master
Patch Set: review comments Created 10 years 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 | « action_processor.h ('k') | 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 16 matching lines...) Expand all
27 public: 27 public:
28 DeltaPerformer(PrefsInterface* prefs) 28 DeltaPerformer(PrefsInterface* prefs)
29 : prefs_(prefs), 29 : prefs_(prefs),
30 fd_(-1), 30 fd_(-1),
31 kernel_fd_(-1), 31 kernel_fd_(-1),
32 manifest_valid_(false), 32 manifest_valid_(false),
33 manifest_metadata_size_(0), 33 manifest_metadata_size_(0),
34 next_operation_num_(0), 34 next_operation_num_(0),
35 buffer_offset_(0), 35 buffer_offset_(0),
36 last_updated_buffer_offset_(kuint64max), 36 last_updated_buffer_offset_(kuint64max),
37 block_size_(0), 37 block_size_(0) {}
38 current_kernel_hash_(NULL),
39 current_rootfs_hash_(NULL) {}
40 38
41 // Opens the kernel. Should be called before or after Open(), but before 39 // Opens the kernel. Should be called before or after Open(), but before
42 // Write(). The kernel file will be close()d when Close() is called. 40 // Write(). The kernel file will be close()d when Close() is called.
43 bool OpenKernel(const char* kernel_path); 41 bool OpenKernel(const char* kernel_path);
44 42
45 // flags and mode ignored. Once Close()d, a DeltaPerformer can't be 43 // flags and mode ignored. Once Close()d, a DeltaPerformer can't be
46 // Open()ed again. 44 // Open()ed again.
47 int Open(const char* path, int flags, mode_t mode); 45 int Open(const char* path, int flags, mode_t mode);
48 46
49 // Wrapper around write. Returns bytes written on success or 47 // Wrapper around write. Returns bytes written on success or
50 // -errno on error. 48 // -errno on error.
51 ssize_t Write(const void* bytes, size_t count); 49 ssize_t Write(const void* bytes, size_t count);
52 50
53 // Wrapper around close. Returns 0 on success or -errno on error. 51 // Wrapper around close. Returns 0 on success or -errno on error.
54 // Closes both 'path' given to Open() and the kernel path. 52 // Closes both 'path' given to Open() and the kernel path.
55 int Close(); 53 int Close();
56 54
57 // Verifies the downloaded payload against the signed hash included in the 55 // Verifies the downloaded payload against the signed hash included in the
58 // payload as well as against the update check hash and size and returns true 56 // payload as well as against the update check hash and size and returns true
59 // on success, false on failure. This method should be called after closing 57 // on success, false on failure. This method should be called after closing
60 // the stream. Note this method skips the signed hash check if the public key 58 // the stream. Note this method skips the signed hash check if the public key
61 // is unavailable; it returns false if the public key is available but the 59 // is unavailable; it returns false if the public key is available but the
62 // delta payload doesn't include a signature. If |public_key_path| is an empty 60 // delta payload doesn't include a signature. If |public_key_path| is an empty
63 // string, uses the default public key path. 61 // string, uses the default public key path.
64 bool VerifyPayload(const std::string& public_key_path, 62 bool VerifyPayload(const std::string& public_key_path,
65 const std::string& update_check_response_hash, 63 const std::string& update_check_response_hash,
66 const uint64_t update_check_response_size); 64 const uint64_t update_check_response_size);
67 65
68 // Verifies that the generated update is correct based on the hashes sent by 66 // Reads from the update manifest the expected sizes and hashes of the target
69 // the server. Returns true on success, false otherwise. 67 // kernel and rootfs partitions. These values can be used for applied update
70 bool VerifyAppliedUpdate(const std::string& path, 68 // hash verification. This method must be called after the update manifest has
71 const std::string& kernel_path); 69 // been parsed (e.g., after closing the stream). Returns true on success, and
70 // false on failure (e.g., when the values are not present in the update
71 // manifest).
72 bool GetNewPartitionInfo(uint64_t* kernel_size,
73 std::vector<char>* kernel_hash,
74 uint64_t* rootfs_size,
75 std::vector<char>* rootfs_hash);
72 76
73 // Converts an ordered collection of Extent objects which contain data of 77 // Converts an ordered collection of Extent objects which contain data of
74 // length full_length to a comma-separated string. For each Extent, the 78 // length full_length to a comma-separated string. For each Extent, the
75 // string will have the start offset and then the length in bytes. 79 // string will have the start offset and then the length in bytes.
76 // The length value of the last extent in the string may be short, since 80 // The length value of the last extent in the string may be short, since
77 // the full length of all extents in the string is capped to full_length. 81 // the full length of all extents in the string is capped to full_length.
78 // Also, an extent starting at kSparseHole, appears as -1 in the string. 82 // Also, an extent starting at kSparseHole, appears as -1 in the string.
79 // For example, if the Extents are {1, 1}, {4, 2}, {kSparseHole, 1}, 83 // For example, if the Extents are {1, 1}, {4, 2}, {kSparseHole, 1},
80 // {0, 1}, block_size is 4096, and full_length is 5 * block_size - 13, 84 // {0, 1}, block_size is 4096, and full_length is 5 * block_size - 13,
81 // the resulting string will be: "4096:4096,16384:8192,-1:4096,0:4083" 85 // the resulting string will be: "4096:4096,16384:8192,-1:4096,0:4083"
82 static bool ExtentsToBsdiffPositionsString( 86 static bool ExtentsToBsdiffPositionsString(
83 const google::protobuf::RepeatedPtrField<Extent>& extents, 87 const google::protobuf::RepeatedPtrField<Extent>& extents,
84 uint64_t block_size, 88 uint64_t block_size,
85 uint64_t full_length, 89 uint64_t full_length,
86 std::string* positions_string); 90 std::string* positions_string);
87 91
88 // Returns true if a previous update attempt can be continued based on the 92 // Returns true if a previous update attempt can be continued based on the
89 // persistent preferences and the new update check response hash. 93 // persistent preferences and the new update check response hash.
90 static bool CanResumeUpdate(PrefsInterface* prefs, 94 static bool CanResumeUpdate(PrefsInterface* prefs,
91 std::string update_check_response_hash); 95 std::string update_check_response_hash);
92 96
93 // Resets the persistent update progress state to indicate that an update 97 // Resets the persistent update progress state to indicate that an update
94 // can't be resumed. Performs a quick update-in-progress reset if |quick| is 98 // can't be resumed. Performs a quick update-in-progress reset if |quick| is
95 // true, otherwise resets all progress-related update state. Returns true on 99 // true, otherwise resets all progress-related update state. Returns true on
96 // success, false otherwise. 100 // success, false otherwise.
97 static bool ResetUpdateProgress(PrefsInterface* prefs, bool quick); 101 static bool ResetUpdateProgress(PrefsInterface* prefs, bool quick);
98 102
99 void set_current_kernel_hash(const std::vector<char>* hash) { 103 void set_current_kernel_hash(const std::vector<char>& hash) {
100 current_kernel_hash_ = hash; 104 current_kernel_hash_ = hash;
101 } 105 }
102 106
103 void set_current_rootfs_hash(const std::vector<char>* hash) { 107 void set_current_rootfs_hash(const std::vector<char>& hash) {
104 current_rootfs_hash_ = hash; 108 current_rootfs_hash_ = hash;
105 } 109 }
106 110
107 private: 111 private:
108 friend class DeltaPerformerTest; 112 friend class DeltaPerformerTest;
109 FRIEND_TEST(DeltaPerformerTest, IsIdempotentOperationTest); 113 FRIEND_TEST(DeltaPerformerTest, IsIdempotentOperationTest);
110 114
111 static bool IsIdempotentOperation( 115 static bool IsIdempotentOperation(
112 const DeltaArchiveManifest_InstallOperation& op); 116 const DeltaArchiveManifest_InstallOperation& op);
113 117
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 OmahaHashCalculator hash_calculator_; 196 OmahaHashCalculator hash_calculator_;
193 197
194 // Saves the signed hash context. 198 // Saves the signed hash context.
195 std::string signed_hash_context_; 199 std::string signed_hash_context_;
196 200
197 // Signatures message blob extracted directly from the payload. 201 // Signatures message blob extracted directly from the payload.
198 std::vector<char> signatures_message_data_; 202 std::vector<char> signatures_message_data_;
199 203
200 // Hashes for the current partitions to be used for source partition 204 // Hashes for the current partitions to be used for source partition
201 // verification. 205 // verification.
202 const std::vector<char>* current_kernel_hash_; 206 std::vector<char> current_kernel_hash_;
203 const std::vector<char>* current_rootfs_hash_; 207 std::vector<char> current_rootfs_hash_;
204 208
205 DISALLOW_COPY_AND_ASSIGN(DeltaPerformer); 209 DISALLOW_COPY_AND_ASSIGN(DeltaPerformer);
206 }; 210 };
207 211
208 } // namespace chromeos_update_engine 212 } // namespace chromeos_update_engine
209 213
210 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__ 214 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__
OLDNEW
« no previous file with comments | « action_processor.h ('k') | delta_performer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698