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

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

Issue 12740002: QUIC/Crypto - Enabled curve25519 key exchange code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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') | no next file » | 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 <string.h>
wtc 2013/03/09 01:23:28 I think you meant to include the C++ header <strin
ramant (doing other things) 2013/03/09 01:38:27 Deleted the include of <string.h>. My mistake. Don
8
9 #include "base/memory/scoped_ptr.h"
10 #include "base/string_piece.h"
7 #include "net/quic/crypto/quic_random.h" 11 #include "net/quic/crypto/quic_random.h"
8 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
9 13
14 using base::StringPiece;
15 using std::string;
16
10 namespace net { 17 namespace net {
11 namespace test { 18 namespace test {
12 19
13 // SharedKey just tests that the basic key exchange identity holds: that both 20 // SharedKey just tests that the basic key exchange identity holds: that both
14 // parties end up with the same key. 21 // parties end up with the same key.
15 TEST(Curve25519KeyExchange, SharedKey) { 22 TEST(Curve25519KeyExchange, SharedKey) {
16 // TODO(rtenneti): Add support for curve25519.
17 #if 0
18 QuicRandom* const rand = QuicRandom::GetInstance(); 23 QuicRandom* const rand = QuicRandom::GetInstance();
19 24
20 for (int i = 0; i < 5; i++) { 25 for (int i = 0; i < 5; i++) {
21 const string alice_key(Curve25519KeyExchange::NewPrivateKey(rand)); 26 const string alice_key(Curve25519KeyExchange::NewPrivateKey(rand));
22 const string bob_key(Curve25519KeyExchange::NewPrivateKey(rand)); 27 const string bob_key(Curve25519KeyExchange::NewPrivateKey(rand));
23 28
24 scoped_ptr<Curve25519KeyExchange> alice(Curve25519KeyExchange::New( 29 scoped_ptr<Curve25519KeyExchange> alice(Curve25519KeyExchange::New(
25 alice_key)); 30 alice_key));
26 scoped_ptr<Curve25519KeyExchange> bob(Curve25519KeyExchange::New( 31 scoped_ptr<Curve25519KeyExchange> bob(Curve25519KeyExchange::New(
27 bob_key)); 32 bob_key));
28 33
29 const StringPiece alice_public(alice->public_value()); 34 const StringPiece alice_public(alice->public_value());
30 const StringPiece bob_public(bob->public_value()); 35 const StringPiece bob_public(bob->public_value());
31 36
32 string alice_shared, bob_shared; 37 string alice_shared, bob_shared;
33 ASSERT_TRUE(alice->CalculateSharedKey(bob_public, &alice_shared)); 38 ASSERT_TRUE(alice->CalculateSharedKey(bob_public, &alice_shared));
34 ASSERT_TRUE(bob->CalculateSharedKey(alice_public, &bob_shared)); 39 ASSERT_TRUE(bob->CalculateSharedKey(alice_public, &bob_shared));
35 ASSERT_EQ(alice_shared, bob_shared); 40 ASSERT_EQ(alice_shared, bob_shared);
36 } 41 }
37 #endif
38 } 42 }
39 43
40 } // namespace test 44 } // namespace test
41 } // namespace net 45 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/curve25519_key_exchange.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698