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

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: support for old-style updates 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
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).
adlr 2010/12/07 02:22:20 explain return value?
petkov 2010/12/07 17:34:02 Done.
70 bool GetNewPartitionInfo(uint64_t* kernel_size,
71 std::vector<char>* kernel_hash,
72 uint64_t* rootfs_size,
73 std::vector<char>* rootfs_hash);
72 74
73 // Converts an ordered collection of Extent objects which contain data of 75 // Converts an ordered collection of Extent objects which contain data of
74 // length full_length to a comma-separated string. For each Extent, the 76 // 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. 77 // 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 78 // 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. 79 // 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. 80 // 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}, 81 // 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, 82 // {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" 83 // the resulting string will be: "4096:4096,16384:8192,-1:4096,0:4083"
82 static bool ExtentsToBsdiffPositionsString( 84 static bool ExtentsToBsdiffPositionsString(
83 const google::protobuf::RepeatedPtrField<Extent>& extents, 85 const google::protobuf::RepeatedPtrField<Extent>& extents,
84 uint64_t block_size, 86 uint64_t block_size,
85 uint64_t full_length, 87 uint64_t full_length,
86 std::string* positions_string); 88 std::string* positions_string);
87 89
88 // Returns true if a previous update attempt can be continued based on the 90 // Returns true if a previous update attempt can be continued based on the
89 // persistent preferences and the new update check response hash. 91 // persistent preferences and the new update check response hash.
90 static bool CanResumeUpdate(PrefsInterface* prefs, 92 static bool CanResumeUpdate(PrefsInterface* prefs,
91 std::string update_check_response_hash); 93 std::string update_check_response_hash);
92 94
93 // Resets the persistent update progress state to indicate that an update 95 // 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 96 // 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 97 // true, otherwise resets all progress-related update state. Returns true on
96 // success, false otherwise. 98 // success, false otherwise.
97 static bool ResetUpdateProgress(PrefsInterface* prefs, bool quick); 99 static bool ResetUpdateProgress(PrefsInterface* prefs, bool quick);
98 100
99 void set_current_kernel_hash(const std::vector<char>* hash) { 101 void set_current_kernel_hash(const std::vector<char> hash) {
adlr 2010/12/07 02:22:20 s/>/>&/
petkov 2010/12/07 17:34:02 Duh.. Done.
100 current_kernel_hash_ = hash; 102 current_kernel_hash_ = hash;
101 } 103 }
102 104
103 void set_current_rootfs_hash(const std::vector<char>* hash) { 105 void set_current_rootfs_hash(const std::vector<char> hash) {
adlr 2010/12/07 02:22:20 s/>/>&/
petkov 2010/12/07 17:34:02 Done.
104 current_rootfs_hash_ = hash; 106 current_rootfs_hash_ = hash;
105 } 107 }
106 108
107 private: 109 private:
108 friend class DeltaPerformerTest; 110 friend class DeltaPerformerTest;
109 FRIEND_TEST(DeltaPerformerTest, IsIdempotentOperationTest); 111 FRIEND_TEST(DeltaPerformerTest, IsIdempotentOperationTest);
110 112
111 static bool IsIdempotentOperation( 113 static bool IsIdempotentOperation(
112 const DeltaArchiveManifest_InstallOperation& op); 114 const DeltaArchiveManifest_InstallOperation& op);
113 115
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 OmahaHashCalculator hash_calculator_; 194 OmahaHashCalculator hash_calculator_;
193 195
194 // Saves the signed hash context. 196 // Saves the signed hash context.
195 std::string signed_hash_context_; 197 std::string signed_hash_context_;
196 198
197 // Signatures message blob extracted directly from the payload. 199 // Signatures message blob extracted directly from the payload.
198 std::vector<char> signatures_message_data_; 200 std::vector<char> signatures_message_data_;
199 201
200 // Hashes for the current partitions to be used for source partition 202 // Hashes for the current partitions to be used for source partition
201 // verification. 203 // verification.
202 const std::vector<char>* current_kernel_hash_; 204 std::vector<char> current_kernel_hash_;
203 const std::vector<char>* current_rootfs_hash_; 205 std::vector<char> current_rootfs_hash_;
204 206
205 DISALLOW_COPY_AND_ASSIGN(DeltaPerformer); 207 DISALLOW_COPY_AND_ASSIGN(DeltaPerformer);
206 }; 208 };
207 209
208 } // namespace chromeos_update_engine 210 } // namespace chromeos_update_engine
209 211
210 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__ 212 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DELTA_PERFORMER_H__
OLDNEW
« no previous file with comments | « action_processor.h ('k') | delta_performer.cc » ('j') | delta_performer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698