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

Side by Side Diff: net/socket/ssl_client_socket_unittest.cc

Issue 1053233003: Fix the OpenSSL implementation of ExportKeyingMaterial. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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/socket/ssl_client_socket_openssl.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/socket/ssl_client_socket.h" 5 #include "net/socket/ssl_client_socket.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 2319 matching lines...) Expand 10 before | Expand all | Expand 10 after
2330 transport.Pass(), test_server.host_port_pair(), SSLConfig())); 2330 transport.Pass(), test_server.host_port_pair(), SSLConfig()));
2331 2331
2332 rv = sock->Connect(callback.callback()); 2332 rv = sock->Connect(callback.callback());
2333 if (rv == ERR_IO_PENDING) 2333 if (rv == ERR_IO_PENDING)
2334 rv = callback.WaitForResult(); 2334 rv = callback.WaitForResult();
2335 EXPECT_EQ(OK, rv); 2335 EXPECT_EQ(OK, rv);
2336 EXPECT_TRUE(sock->IsConnected()); 2336 EXPECT_TRUE(sock->IsConnected());
2337 2337
2338 const int kKeyingMaterialSize = 32; 2338 const int kKeyingMaterialSize = 32;
2339 const char kKeyingLabel1[] = "client-socket-test-1"; 2339 const char kKeyingLabel1[] = "client-socket-test-1";
2340 const char kKeyingContext[] = ""; 2340 const char kKeyingContext1[] = "";
2341 unsigned char client_out1[kKeyingMaterialSize]; 2341 unsigned char client_out1[kKeyingMaterialSize];
2342 memset(client_out1, 0, sizeof(client_out1)); 2342 memset(client_out1, 0, sizeof(client_out1));
2343 rv = sock->ExportKeyingMaterial( 2343 rv = sock->ExportKeyingMaterial(kKeyingLabel1, false, kKeyingContext1,
2344 kKeyingLabel1, false, kKeyingContext, client_out1, sizeof(client_out1)); 2344 client_out1, sizeof(client_out1));
2345 EXPECT_EQ(rv, OK); 2345 EXPECT_EQ(rv, OK);
2346 2346
2347 const char kKeyingLabel2[] = "client-socket-test-2"; 2347 const char kKeyingLabel2[] = "client-socket-test-2";
2348 unsigned char client_out2[kKeyingMaterialSize]; 2348 unsigned char client_out2[kKeyingMaterialSize];
2349 memset(client_out2, 0, sizeof(client_out2)); 2349 memset(client_out2, 0, sizeof(client_out2));
2350 rv = sock->ExportKeyingMaterial( 2350 rv = sock->ExportKeyingMaterial(kKeyingLabel2, false, kKeyingContext1,
2351 kKeyingLabel2, false, kKeyingContext, client_out2, sizeof(client_out2)); 2351 client_out2, sizeof(client_out2));
2352 EXPECT_EQ(rv, OK);
2353 EXPECT_NE(memcmp(client_out1, client_out2, kKeyingMaterialSize), 0);
2354
2355 const char kKeyingContext2[] = "context";
2356 rv = sock->ExportKeyingMaterial(kKeyingLabel1, true, kKeyingContext2,
2357 client_out2, sizeof(client_out2));
2358 EXPECT_EQ(rv, OK);
2359 EXPECT_NE(memcmp(client_out1, client_out2, kKeyingMaterialSize), 0);
2360
2361 // Using an empty context should give different key material from not using a
2362 // context at all.
2363 memset(client_out2, 0, sizeof(client_out2));
2364 rv = sock->ExportKeyingMaterial(kKeyingLabel1, true, kKeyingContext1,
2365 client_out2, sizeof(client_out2));
2352 EXPECT_EQ(rv, OK); 2366 EXPECT_EQ(rv, OK);
2353 EXPECT_NE(memcmp(client_out1, client_out2, kKeyingMaterialSize), 0); 2367 EXPECT_NE(memcmp(client_out1, client_out2, kKeyingMaterialSize), 0);
2354 } 2368 }
2355 2369
2356 // Verifies that SSLClientSocket::ClearSessionCache can be called without 2370 // Verifies that SSLClientSocket::ClearSessionCache can be called without
2357 // explicit NSS initialization. 2371 // explicit NSS initialization.
2358 TEST(SSLClientSocket, ClearSessionCache) { 2372 TEST(SSLClientSocket, ClearSessionCache) {
2359 SSLClientSocket::ClearSessionCache(); 2373 SSLClientSocket::ClearSessionCache();
2360 } 2374 }
2361 2375
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
3099 ssl_config.channel_id_enabled = true; 3113 ssl_config.channel_id_enabled = true;
3100 3114
3101 int rv; 3115 int rv;
3102 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); 3116 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv));
3103 3117
3104 EXPECT_EQ(ERR_UNEXPECTED, rv); 3118 EXPECT_EQ(ERR_UNEXPECTED, rv);
3105 EXPECT_FALSE(sock_->IsConnected()); 3119 EXPECT_FALSE(sock_->IsConnected());
3106 } 3120 }
3107 3121
3108 } // namespace net 3122 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_openssl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698