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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/socket/ssl_client_socket_openssl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/ssl_client_socket_unittest.cc
diff --git a/net/socket/ssl_client_socket_unittest.cc b/net/socket/ssl_client_socket_unittest.cc
index 3a4ff5bfc0deac9c2d85d9593b5cbf64935b354c..82da59497dbfcebdc43e0546b705f342290feb6f 100644
--- a/net/socket/ssl_client_socket_unittest.cc
+++ b/net/socket/ssl_client_socket_unittest.cc
@@ -2337,18 +2337,32 @@ TEST_F(SSLClientSocketTest, ExportKeyingMaterial) {
const int kKeyingMaterialSize = 32;
const char kKeyingLabel1[] = "client-socket-test-1";
- const char kKeyingContext[] = "";
+ const char kKeyingContext1[] = "";
unsigned char client_out1[kKeyingMaterialSize];
memset(client_out1, 0, sizeof(client_out1));
- rv = sock->ExportKeyingMaterial(
- kKeyingLabel1, false, kKeyingContext, client_out1, sizeof(client_out1));
+ rv = sock->ExportKeyingMaterial(kKeyingLabel1, false, kKeyingContext1,
+ client_out1, sizeof(client_out1));
EXPECT_EQ(rv, OK);
const char kKeyingLabel2[] = "client-socket-test-2";
unsigned char client_out2[kKeyingMaterialSize];
memset(client_out2, 0, sizeof(client_out2));
- rv = sock->ExportKeyingMaterial(
- kKeyingLabel2, false, kKeyingContext, client_out2, sizeof(client_out2));
+ rv = sock->ExportKeyingMaterial(kKeyingLabel2, false, kKeyingContext1,
+ client_out2, sizeof(client_out2));
+ EXPECT_EQ(rv, OK);
+ EXPECT_NE(memcmp(client_out1, client_out2, kKeyingMaterialSize), 0);
+
+ const char kKeyingContext2[] = "context";
+ rv = sock->ExportKeyingMaterial(kKeyingLabel1, true, kKeyingContext2,
+ client_out2, sizeof(client_out2));
+ EXPECT_EQ(rv, OK);
+ EXPECT_NE(memcmp(client_out1, client_out2, kKeyingMaterialSize), 0);
+
+ // Using an empty context should give different key material from not using a
+ // context at all.
+ memset(client_out2, 0, sizeof(client_out2));
+ rv = sock->ExportKeyingMaterial(kKeyingLabel1, true, kKeyingContext1,
+ client_out2, sizeof(client_out2));
EXPECT_EQ(rv, OK);
EXPECT_NE(memcmp(client_out1, client_out2, kKeyingMaterialSize), 0);
}
« 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