Make hash checks mandatory for HTTP downloads.

Currently we've made all the checks for metadata size, metadata signature
and operation hashes as optional. While they are still optional if we use
HTTPS for downloading the payload, we want to make them mandatory in case
of HTTP, so as to support HTTP downloads.

In this CL, we make these checks mandatory if the Omaha response has a
HTTP URL. This will not affect any scenarios of our test team because they
always use HTTPS URLs for payload URLs. But this would break the dev tools
and our hardware test lab scenarios because they use HTTP URLs and do not
generate the required manifest signature yet. So we waive this requirement
for dev/test images even though they use HTTP.

This CL will not have any effect until we decide to add a HTTP rule in
Omaha, which serves as a safety knob till we are confident with our
testing.

BUG=chromium-os:36808
TEST=Existing unit tests pass. Added new unit tests for most new code.
TEST=Ran manual tests on ZGB for every type of hash failure for HTTP.
TEST=Tested image_to_live to make sure hash checks are waived as expected.

Change-Id: I8c4408e3052635ccf4bee0c848781733c1f8e984
Reviewed-on: https://gerrit.chromium.org/gerrit/39293
Reviewed-by: Gaurav Shah <gauravsh@chromium.org>
Commit-Ready: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
diff --git a/delta_diff_generator.cc b/delta_diff_generator.cc
index 26f3133..94487c1 100644
--- a/delta_diff_generator.cc
+++ b/delta_diff_generator.cc
@@ -1321,7 +1321,8 @@
     const string& old_kernel_part,
     const string& new_kernel_part,
     const string& output_path,
-    const string& private_key_path) {
+    const string& private_key_path,
+    uint64_t* metadata_size) {
   int old_image_block_count = 0, old_image_block_size = 0;
   int new_image_block_count = 0, new_image_block_size = 0;
   TEST_AND_RETURN_FALSE(utils::GetFilesystemSize(new_image,
@@ -1560,11 +1561,12 @@
                                        signature_blob.size()));
   }
 
-  int64_t manifest_metadata_size =
+  *metadata_size =
       strlen(kDeltaMagic) + 2 * sizeof(uint64_t) + serialized_manifest.size();
-  ReportPayloadUsage(manifest, manifest_metadata_size, op_name_map);
+  ReportPayloadUsage(manifest, *metadata_size, op_name_map);
 
-  LOG(INFO) << "All done. Successfully created delta file.";
+  LOG(INFO) << "All done. Successfully created delta file with "
+            << "metadata size = " << *metadata_size;
   return true;
 }