OLD | NEW |
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 Loading... |
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__ |
OLD | NEW |