Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 403 return server_ssl_->GetDtlsSrtpCipher(retval); | 403 return server_ssl_->GetDtlsSrtpCipher(retval); |
| 404 } | 404 } |
| 405 | 405 |
| 406 bool GetPeerCertificate(bool client, rtc::SSLCertificate** cert) { | 406 bool GetPeerCertificate(bool client, rtc::SSLCertificate** cert) { |
| 407 if (client) | 407 if (client) |
| 408 return client_ssl_->GetPeerCertificate(cert); | 408 return client_ssl_->GetPeerCertificate(cert); |
| 409 else | 409 else |
| 410 return server_ssl_->GetPeerCertificate(cert); | 410 return server_ssl_->GetPeerCertificate(cert); |
| 411 } | 411 } |
| 412 | 412 |
| 413 bool GetSslCipher(bool client, std::string *retval) { | 413 bool GetSslCipher(bool client, uint16_t* retval) { |
| 414 uint16_t cipher; | |
| 415 bool ret; | |
| 414 if (client) | 416 if (client) |
| 415 return client_ssl_->GetSslCipher(retval); | 417 ret = client_ssl_->GetSslCipher(&cipher); |
| 416 else | 418 else |
| 417 return server_ssl_->GetSslCipher(retval); | 419 ret = server_ssl_->GetSslCipher(&cipher); |
| 420 | |
| 421 if (ret) | |
| 422 *retval = cipher; | |
| 423 return ret; | |
|
davidben_webrtc
2015/09/25 19:23:13
Nit: Any reason not to just write this as:
if (
| |
| 418 } | 424 } |
| 419 | 425 |
| 420 bool ExportKeyingMaterial(const char *label, | 426 bool ExportKeyingMaterial(const char *label, |
| 421 const unsigned char *context, | 427 const unsigned char *context, |
| 422 size_t context_len, | 428 size_t context_len, |
| 423 bool use_context, | 429 bool use_context, |
| 424 bool client, | 430 bool client, |
| 425 unsigned char *result, | 431 unsigned char *result, |
| 426 size_t result_len) { | 432 size_t result_len) { |
| 427 if (client) | 433 if (client) |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 965 ASSERT_FALSE(server_peer_cert->GetChain(&server_peer_chain)); | 971 ASSERT_FALSE(server_peer_cert->GetChain(&server_peer_chain)); |
| 966 } | 972 } |
| 967 | 973 |
| 968 // Test getting the used DTLS ciphers. | 974 // Test getting the used DTLS ciphers. |
| 969 // DTLS 1.2 enabled for neither client nor server -> DTLS 1.0 will be used. | 975 // DTLS 1.2 enabled for neither client nor server -> DTLS 1.0 will be used. |
| 970 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipher) { | 976 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipher) { |
| 971 MAYBE_SKIP_TEST(HaveDtls); | 977 MAYBE_SKIP_TEST(HaveDtls); |
| 972 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_10); | 978 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_10); |
| 973 TestHandshake(); | 979 TestHandshake(); |
| 974 | 980 |
| 975 std::string client_cipher; | 981 uint16_t client_cipher; |
| 976 ASSERT_TRUE(GetSslCipher(true, &client_cipher)); | 982 ASSERT_TRUE(GetSslCipher(true, &client_cipher)); |
| 977 std::string server_cipher; | 983 uint16_t server_cipher; |
| 978 ASSERT_TRUE(GetSslCipher(false, &server_cipher)); | 984 ASSERT_TRUE(GetSslCipher(false, &server_cipher)); |
| 979 | 985 |
| 980 ASSERT_EQ(client_cipher, server_cipher); | 986 ASSERT_EQ(client_cipher, server_cipher); |
| 981 ASSERT_EQ(rtc::SSLStreamAdapter::GetDefaultSslCipher( | 987 ASSERT_EQ(rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( |
| 982 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam())), | 988 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam())), |
| 983 server_cipher); | 989 server_cipher); |
| 984 } | 990 } |
| 985 | 991 |
| 986 // Test getting the used DTLS 1.2 ciphers. | 992 // Test getting the used DTLS 1.2 ciphers. |
| 987 // DTLS 1.2 enabled for client and server -> DTLS 1.2 will be used. | 993 // DTLS 1.2 enabled for client and server -> DTLS 1.2 will be used. |
| 988 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherDtls12Both) { | 994 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherDtls12Both) { |
| 989 MAYBE_SKIP_TEST(HaveDtls); | 995 MAYBE_SKIP_TEST(HaveDtls); |
| 990 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_12); | 996 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_12); |
| 991 TestHandshake(); | 997 TestHandshake(); |
| 992 | 998 |
| 993 std::string client_cipher; | 999 uint16_t client_cipher; |
| 994 ASSERT_TRUE(GetSslCipher(true, &client_cipher)); | 1000 ASSERT_TRUE(GetSslCipher(true, &client_cipher)); |
| 995 std::string server_cipher; | 1001 uint16_t server_cipher; |
| 996 ASSERT_TRUE(GetSslCipher(false, &server_cipher)); | 1002 ASSERT_TRUE(GetSslCipher(false, &server_cipher)); |
| 997 | 1003 |
| 998 ASSERT_EQ(client_cipher, server_cipher); | 1004 ASSERT_EQ(client_cipher, server_cipher); |
| 999 ASSERT_EQ(rtc::SSLStreamAdapter::GetDefaultSslCipher( | 1005 ASSERT_EQ(rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( |
| 1000 rtc::SSL_PROTOCOL_DTLS_12, ::testing::get<1>(GetParam())), | 1006 rtc::SSL_PROTOCOL_DTLS_12, ::testing::get<1>(GetParam())), |
| 1001 server_cipher); | 1007 server_cipher); |
| 1002 } | 1008 } |
| 1003 | 1009 |
| 1004 // DTLS 1.2 enabled for client only -> DTLS 1.0 will be used. | 1010 // DTLS 1.2 enabled for client only -> DTLS 1.0 will be used. |
| 1005 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherDtls12Client) { | 1011 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherDtls12Client) { |
| 1006 MAYBE_SKIP_TEST(HaveDtls); | 1012 MAYBE_SKIP_TEST(HaveDtls); |
| 1007 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_12); | 1013 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_12); |
| 1008 TestHandshake(); | 1014 TestHandshake(); |
| 1009 | 1015 |
| 1010 std::string client_cipher; | 1016 uint16_t client_cipher; |
| 1011 ASSERT_TRUE(GetSslCipher(true, &client_cipher)); | 1017 ASSERT_TRUE(GetSslCipher(true, &client_cipher)); |
| 1012 std::string server_cipher; | 1018 uint16_t server_cipher; |
| 1013 ASSERT_TRUE(GetSslCipher(false, &server_cipher)); | 1019 ASSERT_TRUE(GetSslCipher(false, &server_cipher)); |
| 1014 | 1020 |
| 1015 ASSERT_EQ(client_cipher, server_cipher); | 1021 ASSERT_EQ(client_cipher, server_cipher); |
| 1016 ASSERT_EQ(rtc::SSLStreamAdapter::GetDefaultSslCipher( | 1022 ASSERT_EQ(rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( |
| 1017 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam())), | 1023 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam())), |
| 1018 server_cipher); | 1024 server_cipher); |
| 1019 } | 1025 } |
| 1020 | 1026 |
| 1021 // DTLS 1.2 enabled for server only -> DTLS 1.0 will be used. | 1027 // DTLS 1.2 enabled for server only -> DTLS 1.0 will be used. |
| 1022 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherDtls12Server) { | 1028 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherDtls12Server) { |
| 1023 MAYBE_SKIP_TEST(HaveDtls); | 1029 MAYBE_SKIP_TEST(HaveDtls); |
| 1024 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_10); | 1030 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_10); |
| 1025 TestHandshake(); | 1031 TestHandshake(); |
| 1026 | 1032 |
| 1027 std::string client_cipher; | 1033 uint16_t client_cipher; |
| 1028 ASSERT_TRUE(GetSslCipher(true, &client_cipher)); | 1034 ASSERT_TRUE(GetSslCipher(true, &client_cipher)); |
| 1029 std::string server_cipher; | 1035 uint16_t server_cipher; |
| 1030 ASSERT_TRUE(GetSslCipher(false, &server_cipher)); | 1036 ASSERT_TRUE(GetSslCipher(false, &server_cipher)); |
| 1031 | 1037 |
| 1032 ASSERT_EQ(client_cipher, server_cipher); | 1038 ASSERT_EQ(client_cipher, server_cipher); |
| 1033 ASSERT_EQ(rtc::SSLStreamAdapter::GetDefaultSslCipher( | 1039 ASSERT_EQ(rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( |
| 1034 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam())), | 1040 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam())), |
| 1035 server_cipher); | 1041 server_cipher); |
| 1036 } | 1042 } |
| 1037 | 1043 |
| 1038 INSTANTIATE_TEST_CASE_P(SSLStreamAdapterTestsTLS, | 1044 INSTANTIATE_TEST_CASE_P(SSLStreamAdapterTestsTLS, |
| 1039 SSLStreamAdapterTestTLS, | 1045 SSLStreamAdapterTestTLS, |
| 1040 Combine(Values(rtc::KT_RSA, rtc::KT_ECDSA), | 1046 Combine(Values(rtc::KT_RSA, rtc::KT_ECDSA), |
| 1041 Values(rtc::KT_RSA, rtc::KT_ECDSA))); | 1047 Values(rtc::KT_RSA, rtc::KT_ECDSA))); |
| 1042 INSTANTIATE_TEST_CASE_P(SSLStreamAdapterTestsDTLS, | 1048 INSTANTIATE_TEST_CASE_P(SSLStreamAdapterTestsDTLS, |
| 1043 SSLStreamAdapterTestDTLS, | 1049 SSLStreamAdapterTestDTLS, |
| 1044 Combine(Values(rtc::KT_RSA, rtc::KT_ECDSA), | 1050 Combine(Values(rtc::KT_RSA, rtc::KT_ECDSA), |
| 1045 Values(rtc::KT_RSA, rtc::KT_ECDSA))); | 1051 Values(rtc::KT_RSA, rtc::KT_ECDSA))); |
| OLD | NEW |