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

Side by Side Diff: omaha_hash_calculator.h

Issue 6271003: AU: Support signed payload verification through the delta generator. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git@master
Patch Set: Created 9 years, 11 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 | « generate_delta_main.cc ('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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 // Gets the current hash context. Note that the string will contain binary 54 // Gets the current hash context. Note that the string will contain binary
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 RawHashOfBytes(const char* data,
64 size_t length,
65 std::vector<char>* out_hash);
63 static bool RawHashOfData(const std::vector<char>& data, 66 static bool RawHashOfData(const std::vector<char>& data,
64 std::vector<char>* out_hash); 67 std::vector<char>* out_hash);
65 static off_t RawHashOfFile(const std::string& name, off_t length, 68 static off_t RawHashOfFile(const std::string& name, off_t length,
66 std::vector<char>* out_hash); 69 std::vector<char>* out_hash);
67 70
68 // Used by tests 71 // Used by tests
69 static std::string OmahaHashOfBytes(const void* data, size_t length); 72 static std::string OmahaHashOfBytes(const void* data, size_t length);
70 static std::string OmahaHashOfString(const std::string& str); 73 static std::string OmahaHashOfString(const std::string& str);
71 static std::string OmahaHashOfData(const std::vector<char>& data); 74 static std::string OmahaHashOfData(const std::vector<char>& data);
72 75
73 static bool Base64Encode(const void* data, size_t size, std::string* out); 76 static bool Base64Encode(const void* data, size_t size, std::string* out);
74 77
75 private: 78 private:
76 // If non-empty, the final base64 encoded hash and the raw hash. Will only be 79 // If non-empty, the final base64 encoded hash and the raw hash. Will only be
77 // set to non-empty when Finalize is called. 80 // set to non-empty when Finalize is called.
78 std::string hash_; 81 std::string hash_;
79 std::vector<char> raw_hash_; 82 std::vector<char> raw_hash_;
80 83
81 // Init success 84 // Init success
82 bool valid_; 85 bool valid_;
83 86
84 // The hash state used by OpenSSL 87 // The hash state used by OpenSSL
85 SHA256_CTX ctx_; 88 SHA256_CTX ctx_;
86 DISALLOW_COPY_AND_ASSIGN(OmahaHashCalculator); 89 DISALLOW_COPY_AND_ASSIGN(OmahaHashCalculator);
87 }; 90 };
88 91
89 } // namespace chromeos_update_engine 92 } // namespace chromeos_update_engine
90 93
91 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_HASH_CALCULATOR_H__ 94 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_HASH_CALCULATOR_H__
OLDNEW
« no previous file with comments | « generate_delta_main.cc ('k') | omaha_hash_calculator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698