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

Side by Side Diff: net/quic/crypto/curve25519_key_exchange_test.cc

Issue 2193073003: Move shared files in net/quic/ into net/quic/core/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: io_thread_unittest.cc Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « net/quic/crypto/curve25519_key_exchange.cc ('k') | net/quic/crypto/ephemeral_key_source.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/quic/crypto/curve25519_key_exchange.h"
6
7 #include <memory>
8
9 #include "base/strings/string_piece.h"
10 #include "net/quic/crypto/quic_random.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 using base::StringPiece;
14 using std::string;
15
16 namespace net {
17 namespace test {
18
19 // SharedKey just tests that the basic key exchange identity holds: that both
20 // parties end up with the same key.
21 TEST(Curve25519KeyExchange, SharedKey) {
22 QuicRandom* const rand = QuicRandom::GetInstance();
23
24 for (int i = 0; i < 5; i++) {
25 const string alice_key(Curve25519KeyExchange::NewPrivateKey(rand));
26 const string bob_key(Curve25519KeyExchange::NewPrivateKey(rand));
27
28 std::unique_ptr<Curve25519KeyExchange> alice(
29 Curve25519KeyExchange::New(alice_key));
30 std::unique_ptr<Curve25519KeyExchange> bob(
31 Curve25519KeyExchange::New(bob_key));
32
33 const StringPiece alice_public(alice->public_value());
34 const StringPiece bob_public(bob->public_value());
35
36 string alice_shared, bob_shared;
37 ASSERT_TRUE(alice->CalculateSharedKey(bob_public, &alice_shared));
38 ASSERT_TRUE(bob->CalculateSharedKey(alice_public, &bob_shared));
39 ASSERT_EQ(alice_shared, bob_shared);
40 }
41 }
42
43 } // namespace test
44 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/curve25519_key_exchange.cc ('k') | net/quic/crypto/ephemeral_key_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698