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

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

Issue 14816006: Land Recent QUIC changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing NET_PRIVATE_EXPORT to QuicWallTime Created 7 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 unified diff | Download patch | Annotate | Revision Log
« 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
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/crypto/curve25519_key_exchange.h" 5 #include "net/quic/crypto/curve25519_key_exchange.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/string_piece.h" 8 #include "base/strings/string_piece.h"
9 #include "net/quic/crypto/quic_random.h" 9 #include "net/quic/crypto/quic_random.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 using base::StringPiece; 12 using base::StringPiece;
13 using std::string; 13 using std::string;
14 14
15 namespace net { 15 namespace net {
16 namespace test { 16 namespace test {
17 17
18 // SharedKey just tests that the basic key exchange identity holds: that both 18 // SharedKey just tests that the basic key exchange identity holds: that both
19 // parties end up with the same key. 19 // parties end up with the same key.
20 TEST(Curve25519KeyExchange, SharedKey) { 20 TEST(Curve25519KeyExchange, SharedKey) {
21 QuicRandom* const rand = QuicRandom::GetInstance(); 21 QuicRandom* const rand = QuicRandom::GetInstance();
22 22
23 for (int i = 0; i < 5; i++) { 23 for (int i = 0; i < 5; i++) {
24 const string alice_key(Curve25519KeyExchange::NewPrivateKey(rand)); 24 const string alice_key(Curve25519KeyExchange::NewPrivateKey(rand));
25 const string bob_key(Curve25519KeyExchange::NewPrivateKey(rand)); 25 const string bob_key(Curve25519KeyExchange::NewPrivateKey(rand));
26 26
27 scoped_ptr<Curve25519KeyExchange> alice(Curve25519KeyExchange::New( 27 scoped_ptr<Curve25519KeyExchange> alice(
28 alice_key)); 28 Curve25519KeyExchange::New(alice_key));
29 scoped_ptr<Curve25519KeyExchange> bob(Curve25519KeyExchange::New( 29 scoped_ptr<Curve25519KeyExchange> bob(Curve25519KeyExchange::New(bob_key));
30 bob_key));
31 30
32 const StringPiece alice_public(alice->public_value()); 31 const StringPiece alice_public(alice->public_value());
33 const StringPiece bob_public(bob->public_value()); 32 const StringPiece bob_public(bob->public_value());
34 33
35 string alice_shared, bob_shared; 34 string alice_shared, bob_shared;
36 ASSERT_TRUE(alice->CalculateSharedKey(bob_public, &alice_shared)); 35 ASSERT_TRUE(alice->CalculateSharedKey(bob_public, &alice_shared));
37 ASSERT_TRUE(bob->CalculateSharedKey(alice_public, &bob_shared)); 36 ASSERT_TRUE(bob->CalculateSharedKey(alice_public, &bob_shared));
38 ASSERT_EQ(alice_shared, bob_shared); 37 ASSERT_EQ(alice_shared, bob_shared);
39 } 38 }
40 } 39 }
41 40
42 } // namespace test 41 } // namespace test
43 } // namespace net 42 } // 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