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

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

Issue 2848203002: Add a platform implementation of QuicTest and QuicTestWithParam (Closed)
Patch Set: net/quic/platform/impl/quic_test_impl.cc 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 unified diff | Download patch
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/core/crypto/p256_key_exchange.h" 5 #include "net/quic/core/crypto/p256_key_exchange.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "net/quic/platform/api/quic_test.h"
10 10
11 using std::string; 11 using std::string;
12 12
13 namespace net { 13 namespace net {
14 namespace test { 14 namespace test {
15 15
16 class P256KeyExchangeTest : public QuicTest {};
17
16 // 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
17 // parties end up with the same key. 19 // parties end up with the same key.
18 TEST(P256KeyExchange, SharedKey) { 20 TEST_F(P256KeyExchangeTest, SharedKey) {
19 for (int i = 0; i < 5; i++) { 21 for (int i = 0; i < 5; i++) {
20 string alice_private(P256KeyExchange::NewPrivateKey()); 22 string alice_private(P256KeyExchange::NewPrivateKey());
21 string bob_private(P256KeyExchange::NewPrivateKey()); 23 string bob_private(P256KeyExchange::NewPrivateKey());
22 24
23 ASSERT_FALSE(alice_private.empty()); 25 ASSERT_FALSE(alice_private.empty());
24 ASSERT_FALSE(bob_private.empty()); 26 ASSERT_FALSE(bob_private.empty());
25 ASSERT_NE(alice_private, bob_private); 27 ASSERT_NE(alice_private, bob_private);
26 28
27 std::unique_ptr<P256KeyExchange> alice(P256KeyExchange::New(alice_private)); 29 std::unique_ptr<P256KeyExchange> alice(P256KeyExchange::New(alice_private));
28 std::unique_ptr<P256KeyExchange> bob(P256KeyExchange::New(bob_private)); 30 std::unique_ptr<P256KeyExchange> bob(P256KeyExchange::New(bob_private));
29 31
30 ASSERT_TRUE(alice.get() != nullptr); 32 ASSERT_TRUE(alice.get() != nullptr);
31 ASSERT_TRUE(bob.get() != nullptr); 33 ASSERT_TRUE(bob.get() != nullptr);
32 34
33 const QuicStringPiece alice_public(alice->public_value()); 35 const QuicStringPiece alice_public(alice->public_value());
34 const QuicStringPiece bob_public(bob->public_value()); 36 const QuicStringPiece bob_public(bob->public_value());
35 37
36 std::string alice_shared, bob_shared; 38 std::string alice_shared, bob_shared;
37 ASSERT_TRUE(alice->CalculateSharedKey(bob_public, &alice_shared)); 39 ASSERT_TRUE(alice->CalculateSharedKey(bob_public, &alice_shared));
38 ASSERT_TRUE(bob->CalculateSharedKey(alice_public, &bob_shared)); 40 ASSERT_TRUE(bob->CalculateSharedKey(alice_public, &bob_shared));
39 ASSERT_EQ(alice_shared, bob_shared); 41 ASSERT_EQ(alice_shared, bob_shared);
40 } 42 }
41 } 43 }
42 44
43 } // namespace test 45 } // namespace test
44 } // namespace net 46 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/crypto/null_encrypter_test.cc ('k') | net/quic/core/crypto/quic_compressed_certs_cache_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698