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

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

Issue 612323013: QUIC - (no behavior change) s/NULL/nullptr/g in .../quic/... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 unified diff | Download patch
« no previous file with comments | « net/quic/crypto/p256_key_exchange_openssl.cc ('k') | net/quic/crypto/proof_test.cc » ('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/p256_key_exchange.h" 5 #include "net/quic/crypto/p256_key_exchange.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 using std::string; 10 using std::string;
11 11
12 namespace net { 12 namespace net {
13 namespace test { 13 namespace test {
14 14
15 // SharedKey just tests that the basic key exchange identity holds: that both 15 // SharedKey just tests that the basic key exchange identity holds: that both
16 // parties end up with the same key. 16 // parties end up with the same key.
17 TEST(P256KeyExchange, SharedKey) { 17 TEST(P256KeyExchange, SharedKey) {
18 for (int i = 0; i < 5; i++) { 18 for (int i = 0; i < 5; i++) {
19 string alice_private(P256KeyExchange::NewPrivateKey()); 19 string alice_private(P256KeyExchange::NewPrivateKey());
20 string bob_private(P256KeyExchange::NewPrivateKey()); 20 string bob_private(P256KeyExchange::NewPrivateKey());
21 21
22 ASSERT_FALSE(alice_private.empty()); 22 ASSERT_FALSE(alice_private.empty());
23 ASSERT_FALSE(bob_private.empty()); 23 ASSERT_FALSE(bob_private.empty());
24 ASSERT_NE(alice_private, bob_private); 24 ASSERT_NE(alice_private, bob_private);
25 25
26 scoped_ptr<P256KeyExchange> alice(P256KeyExchange::New(alice_private)); 26 scoped_ptr<P256KeyExchange> alice(P256KeyExchange::New(alice_private));
27 scoped_ptr<P256KeyExchange> bob(P256KeyExchange::New(bob_private)); 27 scoped_ptr<P256KeyExchange> bob(P256KeyExchange::New(bob_private));
28 28
29 ASSERT_TRUE(alice.get() != NULL); 29 ASSERT_TRUE(alice.get() != nullptr);
30 ASSERT_TRUE(bob.get() != NULL); 30 ASSERT_TRUE(bob.get() != nullptr);
31 31
32 const base::StringPiece alice_public(alice->public_value()); 32 const base::StringPiece alice_public(alice->public_value());
33 const base::StringPiece bob_public(bob->public_value()); 33 const base::StringPiece bob_public(bob->public_value());
34 34
35 std::string alice_shared, bob_shared; 35 std::string alice_shared, bob_shared;
36 ASSERT_TRUE(alice->CalculateSharedKey(bob_public, &alice_shared)); 36 ASSERT_TRUE(alice->CalculateSharedKey(bob_public, &alice_shared));
37 ASSERT_TRUE(bob->CalculateSharedKey(alice_public, &bob_shared)); 37 ASSERT_TRUE(bob->CalculateSharedKey(alice_public, &bob_shared));
38 ASSERT_EQ(alice_shared, bob_shared); 38 ASSERT_EQ(alice_shared, bob_shared);
39 } 39 }
40 } 40 }
41 41
42 } // namespace test 42 } // namespace test
43 } // namespace net 43 } // namespace net
44 44
OLDNEW
« no previous file with comments | « net/quic/crypto/p256_key_exchange_openssl.cc ('k') | net/quic/crypto/proof_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698