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

Unified Diff: omaha_hash_calculator.cc

Issue 3592008: AU: Verify delta payload signature and signed hash. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: move /tmp files to /var/run 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « omaha_hash_calculator.h ('k') | omaha_hash_calculator_unittest.cc » ('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 88bfc6d837c4d9399aaa38bc6672be73ad769b35..0df83bcd99598ba99f1a0697a6b16657401ae71e 100644
--- a/omaha_hash_calculator.cc
+++ b/omaha_hash_calculator.cc
@@ -36,10 +36,13 @@ bool OmahaHashCalculator::Update(const char* data, size_t length) {
bool OmahaHashCalculator::Finalize() {
bool success = true;
TEST_AND_RETURN_FALSE(hash_.empty());
- unsigned char md[SHA256_DIGEST_LENGTH];
- TEST_AND_RETURN_FALSE(SHA256_Final(md, &ctx_) == 1);
+ TEST_AND_RETURN_FALSE(raw_hash_.empty());
+ raw_hash_.resize(SHA256_DIGEST_LENGTH);
+ TEST_AND_RETURN_FALSE(
+ SHA256_Final(reinterpret_cast<unsigned char*>(&raw_hash_[0]),
+ &ctx_) == 1);
- // Convert md to base64 encoding and store it in hash_
+ // Convert raw_hash_ to base64 encoding and store it in hash_.
BIO *b64 = BIO_new(BIO_f_base64());
if (!b64)
LOG(INFO) << "BIO_new(BIO_f_base64()) failed";
@@ -48,7 +51,9 @@ bool OmahaHashCalculator::Finalize() {
LOG(INFO) << "BIO_new(BIO_s_mem()) failed";
if (b64 && bmem) {
b64 = BIO_push(b64, bmem);
- success = (BIO_write(b64, md, sizeof(md)) == sizeof(md));
+ success =
+ (BIO_write(b64, &raw_hash_[0], raw_hash_.size()) ==
+ static_cast<int>(raw_hash_.size()));
if (success)
success = (BIO_flush(b64) == 1);
« no previous file with comments | « omaha_hash_calculator.h ('k') | omaha_hash_calculator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698