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

Unified Diff: components/cryptauth/session_keys_unittest.cc

Issue 2899863002: Updating D2D protocol to v1 to support separate sequence numbers. (Closed)
Patch Set: Addressing comments Created 3 years, 7 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 | « components/cryptauth/session_keys.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cryptauth/session_keys_unittest.cc
diff --git a/components/cryptauth/session_keys_unittest.cc b/components/cryptauth/session_keys_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e11b8c6b7388de388379daec3e615a31e3c2dfa9
--- /dev/null
+++ b/components/cryptauth/session_keys_unittest.cc
@@ -0,0 +1,56 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/cryptauth/session_keys.h"
+
+#include <string>
+#include <vector>
+
+#include "base/macros.h"
+#include "base/strings/string_number_conversions.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace cryptauth {
+namespace {
+
+// Values generated using the Android implementation.
+const char kMasterKeyHex[] =
+ "f611126a04302551ac1e8ed512952ee287a1d2561e2a2c72e7bf1ebe4bdc74ce";
+const char kInitiatorKeyHex[] =
+ "787ec48783f0a1f9fb9c5bc0230c2e7f45b8783acf8c9bd1c63242df9da31999";
+const char kResponderKeyHex[] =
+ "a366ec1f9cf327b69c341211216545cc302379078229eae78b43d60c110a6fba";
+
+} // namespace
+
+class CryptAuthSessionKeysTest : public testing::Test {
+ protected:
+ CryptAuthSessionKeysTest() {}
+
+ DISALLOW_COPY_AND_ASSIGN(CryptAuthSessionKeysTest);
+};
+
+TEST_F(CryptAuthSessionKeysTest, GenerateKeys) {
+ std::vector<uint8_t> data;
+
+ std::string master_key(kMasterKeyHex);
+ ASSERT_TRUE(base::HexStringToBytes(master_key, &data));
+ master_key.assign(reinterpret_cast<char*>(&data[0]), data.size());
+
+ data.clear();
+ std::string initiator_key(kInitiatorKeyHex);
+ ASSERT_TRUE(base::HexStringToBytes(initiator_key, &data));
+ initiator_key.assign(reinterpret_cast<char*>(&data[0]), data.size());
+
+ data.clear();
+ std::string responder_key(kResponderKeyHex);
+ ASSERT_TRUE(base::HexStringToBytes(responder_key, &data));
+ responder_key.assign(reinterpret_cast<char*>(&data[0]), data.size());
+
+ SessionKeys session_keys(master_key);
+ EXPECT_EQ(initiator_key, session_keys.initiator_encode_key());
+ EXPECT_EQ(responder_key, session_keys.responder_encode_key());
+}
+
+} // namespace cryptauth
« no previous file with comments | « components/cryptauth/session_keys.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698