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

Side by Side Diff: webrtc/base/sslstreamadapter_unittest.cc

Issue 1774583002: Add IsAcceptableCipher, use instead of GetDefaultCipher. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: List another cipher suite Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 MAYBE_SKIP_TEST(HaveDtls); 1070 MAYBE_SKIP_TEST(HaveDtls);
1071 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_10); 1071 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_10);
1072 TestHandshake(); 1072 TestHandshake();
1073 1073
1074 int client_cipher; 1074 int client_cipher;
1075 ASSERT_TRUE(GetSslCipherSuite(true, &client_cipher)); 1075 ASSERT_TRUE(GetSslCipherSuite(true, &client_cipher));
1076 int server_cipher; 1076 int server_cipher;
1077 ASSERT_TRUE(GetSslCipherSuite(false, &server_cipher)); 1077 ASSERT_TRUE(GetSslCipherSuite(false, &server_cipher));
1078 1078
1079 ASSERT_EQ(client_cipher, server_cipher); 1079 ASSERT_EQ(client_cipher, server_cipher);
1080 ASSERT_EQ( 1080 ASSERT_TRUE(rtc::SSLStreamAdapter::IsAcceptableCipher(
1081 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( 1081 server_cipher, rtc::SSL_PROTOCOL_DTLS_10,
1082 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam()).type()), 1082 ::testing::get<1>(GetParam()).type()));
1083 server_cipher);
1084 } 1083 }
1085 1084
1086 // Test getting the used DTLS 1.2 ciphers. 1085 // Test getting the used DTLS 1.2 ciphers.
1087 // DTLS 1.2 enabled for client and server -> DTLS 1.2 will be used. 1086 // DTLS 1.2 enabled for client and server -> DTLS 1.2 will be used.
1088 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherSuiteDtls12Both) { 1087 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherSuiteDtls12Both) {
1089 MAYBE_SKIP_TEST(HaveDtls); 1088 MAYBE_SKIP_TEST(HaveDtls);
1090 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_12); 1089 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_12);
1091 TestHandshake(); 1090 TestHandshake();
1092 1091
1093 int client_cipher; 1092 int client_cipher;
1094 ASSERT_TRUE(GetSslCipherSuite(true, &client_cipher)); 1093 ASSERT_TRUE(GetSslCipherSuite(true, &client_cipher));
1095 int server_cipher; 1094 int server_cipher;
1096 ASSERT_TRUE(GetSslCipherSuite(false, &server_cipher)); 1095 ASSERT_TRUE(GetSslCipherSuite(false, &server_cipher));
1097 1096
1098 ASSERT_EQ(client_cipher, server_cipher); 1097 ASSERT_EQ(client_cipher, server_cipher);
1099 ASSERT_EQ( 1098 ASSERT_TRUE(rtc::SSLStreamAdapter::IsAcceptableCipher(
1100 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( 1099 server_cipher, rtc::SSL_PROTOCOL_DTLS_12,
1101 rtc::SSL_PROTOCOL_DTLS_12, ::testing::get<1>(GetParam()).type()), 1100 ::testing::get<1>(GetParam()).type()));
1102 server_cipher);
1103 } 1101 }
1104 1102
1105 // DTLS 1.2 enabled for client only -> DTLS 1.0 will be used. 1103 // DTLS 1.2 enabled for client only -> DTLS 1.0 will be used.
1106 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherSuiteDtls12Client) { 1104 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherSuiteDtls12Client) {
1107 MAYBE_SKIP_TEST(HaveDtls); 1105 MAYBE_SKIP_TEST(HaveDtls);
1108 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_12); 1106 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_12);
1109 TestHandshake(); 1107 TestHandshake();
1110 1108
1111 int client_cipher; 1109 int client_cipher;
1112 ASSERT_TRUE(GetSslCipherSuite(true, &client_cipher)); 1110 ASSERT_TRUE(GetSslCipherSuite(true, &client_cipher));
1113 int server_cipher; 1111 int server_cipher;
1114 ASSERT_TRUE(GetSslCipherSuite(false, &server_cipher)); 1112 ASSERT_TRUE(GetSslCipherSuite(false, &server_cipher));
1115 1113
1116 ASSERT_EQ(client_cipher, server_cipher); 1114 ASSERT_EQ(client_cipher, server_cipher);
1117 ASSERT_EQ( 1115 ASSERT_TRUE(rtc::SSLStreamAdapter::IsAcceptableCipher(
1118 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( 1116 server_cipher, rtc::SSL_PROTOCOL_DTLS_10,
1119 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam()).type()), 1117 ::testing::get<1>(GetParam()).type()));
1120 server_cipher);
1121 } 1118 }
1122 1119
1123 // DTLS 1.2 enabled for server only -> DTLS 1.0 will be used. 1120 // DTLS 1.2 enabled for server only -> DTLS 1.0 will be used.
1124 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherSuiteDtls12Server) { 1121 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherSuiteDtls12Server) {
1125 MAYBE_SKIP_TEST(HaveDtls); 1122 MAYBE_SKIP_TEST(HaveDtls);
1126 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_10); 1123 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_10);
1127 TestHandshake(); 1124 TestHandshake();
1128 1125
1129 int client_cipher; 1126 int client_cipher;
1130 ASSERT_TRUE(GetSslCipherSuite(true, &client_cipher)); 1127 ASSERT_TRUE(GetSslCipherSuite(true, &client_cipher));
1131 int server_cipher; 1128 int server_cipher;
1132 ASSERT_TRUE(GetSslCipherSuite(false, &server_cipher)); 1129 ASSERT_TRUE(GetSslCipherSuite(false, &server_cipher));
1133 1130
1134 ASSERT_EQ(client_cipher, server_cipher); 1131 ASSERT_EQ(client_cipher, server_cipher);
1135 ASSERT_EQ( 1132 ASSERT_TRUE(rtc::SSLStreamAdapter::IsAcceptableCipher(
1136 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( 1133 server_cipher, rtc::SSL_PROTOCOL_DTLS_10,
1137 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam()).type()), 1134 ::testing::get<1>(GetParam()).type()));
1138 server_cipher);
1139 } 1135 }
1140 1136
1141 // The RSA keysizes here might look strange, why not include the RFC's size 1137 // The RSA keysizes here might look strange, why not include the RFC's size
1142 // 2048?. The reason is test case slowness; testing two sizes to exercise 1138 // 2048?. The reason is test case slowness; testing two sizes to exercise
1143 // parametrization is sufficient. 1139 // parametrization is sufficient.
1144 INSTANTIATE_TEST_CASE_P( 1140 INSTANTIATE_TEST_CASE_P(
1145 SSLStreamAdapterTestsTLS, 1141 SSLStreamAdapterTestsTLS,
1146 SSLStreamAdapterTestTLS, 1142 SSLStreamAdapterTestTLS,
1147 Combine(Values(rtc::KeyParams::RSA(1024, 65537), 1143 Combine(Values(rtc::KeyParams::RSA(1024, 65537),
1148 rtc::KeyParams::RSA(1152, 65537), 1144 rtc::KeyParams::RSA(1152, 65537),
1149 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)), 1145 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)),
1150 Values(rtc::KeyParams::RSA(1024, 65537), 1146 Values(rtc::KeyParams::RSA(1024, 65537),
1151 rtc::KeyParams::RSA(1152, 65537), 1147 rtc::KeyParams::RSA(1152, 65537),
1152 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)))); 1148 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256))));
1153 INSTANTIATE_TEST_CASE_P( 1149 INSTANTIATE_TEST_CASE_P(
1154 SSLStreamAdapterTestsDTLS, 1150 SSLStreamAdapterTestsDTLS,
1155 SSLStreamAdapterTestDTLS, 1151 SSLStreamAdapterTestDTLS,
1156 Combine(Values(rtc::KeyParams::RSA(1024, 65537), 1152 Combine(Values(rtc::KeyParams::RSA(1024, 65537),
1157 rtc::KeyParams::RSA(1152, 65537), 1153 rtc::KeyParams::RSA(1152, 65537),
1158 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)), 1154 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)),
1159 Values(rtc::KeyParams::RSA(1024, 65537), 1155 Values(rtc::KeyParams::RSA(1024, 65537),
1160 rtc::KeyParams::RSA(1152, 65537), 1156 rtc::KeyParams::RSA(1152, 65537),
1161 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)))); 1157 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256))));
OLDNEW
« webrtc/api/peerconnection_unittest.cc ('K') | « webrtc/base/sslstreamadapter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698