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

Side by Side Diff: omaha_hash_calculator.h

Issue 3712003: AU: Verify source rootfs/kernel hashes before applying delta. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: verify source partitions only for new updates 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 | « install_plan.h ('k') | omaha_hash_calculator.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) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 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_OMAHA_HASH_CALCULATOR_H__ 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_HASH_CALCULATOR_H__
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_HASH_CALCULATOR_H__ 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_HASH_CALCULATOR_H__
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // data (including \0 characters). 55 // data (including \0 characters).
56 std::string GetContext() const; 56 std::string GetContext() const;
57 57
58 // Sets the current hash context. |context| must the string returned by a 58 // Sets the current hash context. |context| must the string returned by a
59 // previous OmahaHashCalculator::GetContext method call. Returns true on 59 // previous OmahaHashCalculator::GetContext method call. Returns true on
60 // success, and false otherwise. 60 // success, and false otherwise.
61 bool SetContext(const std::string& context); 61 bool SetContext(const std::string& context);
62 62
63 static bool RawHashOfData(const std::vector<char>& data, 63 static bool RawHashOfData(const std::vector<char>& data,
64 std::vector<char>* out_hash); 64 std::vector<char>* out_hash);
65 static off_t RawHashOfFile(const std::string& name, off_t length,
66 std::vector<char>* out_hash);
65 67
66 // Used by tests 68 // Used by tests
67 static std::string OmahaHashOfBytes(const void* data, size_t length); 69 static std::string OmahaHashOfBytes(const void* data, size_t length);
68 static std::string OmahaHashOfString(const std::string& str); 70 static std::string OmahaHashOfString(const std::string& str);
69 static std::string OmahaHashOfData(const std::vector<char>& data); 71 static std::string OmahaHashOfData(const std::vector<char>& data);
70 72
71 private: 73 private:
72 // If non-empty, the final base64 encoded hash and the raw hash. Will only be 74 // If non-empty, the final base64 encoded hash and the raw hash. Will only be
73 // set to non-empty when Finalize is called. 75 // set to non-empty when Finalize is called.
74 std::string hash_; 76 std::string hash_;
75 std::vector<char> raw_hash_; 77 std::vector<char> raw_hash_;
76 78
77 // Init success 79 // Init success
78 bool valid_; 80 bool valid_;
79 81
80 // The hash state used by OpenSSL 82 // The hash state used by OpenSSL
81 SHA256_CTX ctx_; 83 SHA256_CTX ctx_;
82 DISALLOW_COPY_AND_ASSIGN(OmahaHashCalculator); 84 DISALLOW_COPY_AND_ASSIGN(OmahaHashCalculator);
83 }; 85 };
84 86
85 } // namespace chromeos_update_engine 87 } // namespace chromeos_update_engine
86 88
87 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_HASH_CALCULATOR_H__ 89 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_HASH_CALCULATOR_H__
OLDNEW
« no previous file with comments | « install_plan.h ('k') | omaha_hash_calculator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698