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

Unified Diff: omaha_hash_calculator.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « omaha_hash_calculator.h ('k') | payload_signer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: omaha_hash_calculator.cc
diff --git a/omaha_hash_calculator.cc b/omaha_hash_calculator.cc
index cf583a9f8dac7fc3d24399299856907a59ef0a7c..de70d10631bc07852fe815b45e4f136d7fb77a8a 100644
--- a/omaha_hash_calculator.cc
+++ b/omaha_hash_calculator.cc
@@ -105,21 +105,23 @@ bool OmahaHashCalculator::Finalize() {
return Base64Encode(&raw_hash_[0], raw_hash_.size(), &hash_);;
}
-bool OmahaHashCalculator::RawHashOfData(const vector<char>& data,
- vector<char>* out_hash) {
+bool OmahaHashCalculator::RawHashOfBytes(const char* data,
+ size_t length,
+ vector<char>* out_hash) {
OmahaHashCalculator calc;
- calc.Update(&data[0], data.size());
-
- out_hash->resize(out_hash->size() + SHA256_DIGEST_LENGTH);
- TEST_AND_RETURN_FALSE(
- SHA256_Final(reinterpret_cast<unsigned char*>(&(*(out_hash->end() -
- SHA256_DIGEST_LENGTH))),
- &calc.ctx_) == 1);
+ TEST_AND_RETURN_FALSE(calc.Update(data, length));
+ TEST_AND_RETURN_FALSE(calc.Finalize());
+ *out_hash = calc.raw_hash();
return true;
}
-off_t OmahaHashCalculator::RawHashOfFile(const std::string& name, off_t length,
- std::vector<char>* out_hash) {
+bool OmahaHashCalculator::RawHashOfData(const vector<char>& data,
+ vector<char>* out_hash) {
+ return RawHashOfBytes(data.data(), data.size(), out_hash);
+}
+
+off_t OmahaHashCalculator::RawHashOfFile(const string& name, off_t length,
+ vector<char>* out_hash) {
OmahaHashCalculator calc;
off_t res = calc.UpdateFile(name, length);
if (res < 0) {
« no previous file with comments | « omaha_hash_calculator.h ('k') | payload_signer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698