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

Unified Diff: omaha_hash_calculator_unittest.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.cc ('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_unittest.cc
diff --git a/omaha_hash_calculator_unittest.cc b/omaha_hash_calculator_unittest.cc
index d228f12641ddab3d3f048fa94c70fa2f5ad9453c..449cb9021e487a728c1a07a5b7e5f72992cb6743 100644
--- a/omaha_hash_calculator_unittest.cc
+++ b/omaha_hash_calculator_unittest.cc
@@ -4,22 +4,40 @@
#include <math.h>
#include <unistd.h>
+
+#include <vector>
+
#include <glib.h>
#include <gtest/gtest.h>
+
#include "update_engine/libcurl_http_fetcher.h"
#include "update_engine/omaha_hash_calculator.h"
+using std::vector;
+
namespace chromeos_update_engine {
class OmahaHashCalculatorTest : public ::testing::Test { };
+// Generated by running this on a linux shell:
+// $ echo -n hi | openssl dgst -sha256 -binary | openssl base64
+static const char kExpectedHash[] =
+ "j0NDRmSPa5bfid2pAcUXaxCm2Dlh3TwayItZstwyeqQ=";
+static const char kExpectedRawHash[] = {
+ 0x8f, 0x43, 0x43, 0x46, 0x64, 0x8f, 0x6b, 0x96,
+ 0xdf, 0x89, 0xdd, 0xa9, 0x01, 0xc5, 0x17, 0x6b,
+ 0x10, 0xa6, 0xd8, 0x39, 0x61, 0xdd, 0x3c, 0x1a,
+ 0xc8, 0x8b, 0x59, 0xb2, 0xdc, 0x32, 0x7a, 0xa4
+};
+
TEST(OmahaHashCalculatorTest, SimpleTest) {
OmahaHashCalculator calc;
calc.Update("hi", 2);
calc.Finalize();
- // Generated by running this on a linux shell:
- // $ echo -n hi | openssl dgst -sha256 -binary | openssl base64
- EXPECT_EQ("j0NDRmSPa5bfid2pAcUXaxCm2Dlh3TwayItZstwyeqQ=", calc.hash());
+ EXPECT_EQ(kExpectedHash, calc.hash());
+ vector<char> raw_hash(kExpectedRawHash,
+ kExpectedRawHash + arraysize(kExpectedRawHash));
+ EXPECT_TRUE(raw_hash == calc.raw_hash());
}
TEST(OmahaHashCalculatorTest, MultiUpdateTest) {
@@ -27,9 +45,10 @@ TEST(OmahaHashCalculatorTest, MultiUpdateTest) {
calc.Update("h", 1);
calc.Update("i", 1);
calc.Finalize();
- // Generated by running this on a linux shell:
- // $ echo -n hi | openssl dgst -sha256 -binary | openssl base64
- EXPECT_EQ("j0NDRmSPa5bfid2pAcUXaxCm2Dlh3TwayItZstwyeqQ=", calc.hash());
+ EXPECT_EQ(kExpectedHash, calc.hash());
+ vector<char> raw_hash(kExpectedRawHash,
+ kExpectedRawHash + arraysize(kExpectedRawHash));
+ EXPECT_TRUE(raw_hash == calc.raw_hash());
}
TEST(OmahaHashCalculatorTest, BigTest) {
« no previous file with comments | « omaha_hash_calculator.cc ('k') | payload_signer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698