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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, std::string *retval) { |
| 414 SslCipher 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.rfc_name; |
| 423 return ret; |
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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 std::string client_cipher; |
976 ASSERT_TRUE(GetSslCipher(true, &client_cipher)); | 982 ASSERT_TRUE(GetSslCipher(true, &client_cipher)); |
977 std::string server_cipher; | 983 std::string 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( |
982 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam())), | 988 rtc::SSLStreamAdapter::GetDefaultSslCipher( |
983 server_cipher); | 989 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam())).rfc_name, |
| 990 server_cipher); |
984 } | 991 } |
985 | 992 |
986 // Test getting the used DTLS 1.2 ciphers. | 993 // Test getting the used DTLS 1.2 ciphers. |
987 // DTLS 1.2 enabled for client and server -> DTLS 1.2 will be used. | 994 // DTLS 1.2 enabled for client and server -> DTLS 1.2 will be used. |
988 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherDtls12Both) { | 995 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherDtls12Both) { |
989 MAYBE_SKIP_TEST(HaveDtls); | 996 MAYBE_SKIP_TEST(HaveDtls); |
990 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_12); | 997 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_12); |
991 TestHandshake(); | 998 TestHandshake(); |
992 | 999 |
993 std::string client_cipher; | 1000 std::string client_cipher; |
994 ASSERT_TRUE(GetSslCipher(true, &client_cipher)); | 1001 ASSERT_TRUE(GetSslCipher(true, &client_cipher)); |
995 std::string server_cipher; | 1002 std::string server_cipher; |
996 ASSERT_TRUE(GetSslCipher(false, &server_cipher)); | 1003 ASSERT_TRUE(GetSslCipher(false, &server_cipher)); |
997 | 1004 |
998 ASSERT_EQ(client_cipher, server_cipher); | 1005 ASSERT_EQ(client_cipher, server_cipher); |
999 ASSERT_EQ(rtc::SSLStreamAdapter::GetDefaultSslCipher( | 1006 ASSERT_EQ( |
1000 rtc::SSL_PROTOCOL_DTLS_12, ::testing::get<1>(GetParam())), | 1007 rtc::SSLStreamAdapter::GetDefaultSslCipher( |
1001 server_cipher); | 1008 rtc::SSL_PROTOCOL_DTLS_12, ::testing::get<1>(GetParam())).rfc_name, |
| 1009 server_cipher); |
1002 } | 1010 } |
1003 | 1011 |
1004 // DTLS 1.2 enabled for client only -> DTLS 1.0 will be used. | 1012 // DTLS 1.2 enabled for client only -> DTLS 1.0 will be used. |
1005 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherDtls12Client) { | 1013 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherDtls12Client) { |
1006 MAYBE_SKIP_TEST(HaveDtls); | 1014 MAYBE_SKIP_TEST(HaveDtls); |
1007 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_12); | 1015 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_12); |
1008 TestHandshake(); | 1016 TestHandshake(); |
1009 | 1017 |
1010 std::string client_cipher; | 1018 std::string client_cipher; |
1011 ASSERT_TRUE(GetSslCipher(true, &client_cipher)); | 1019 ASSERT_TRUE(GetSslCipher(true, &client_cipher)); |
1012 std::string server_cipher; | 1020 std::string server_cipher; |
1013 ASSERT_TRUE(GetSslCipher(false, &server_cipher)); | 1021 ASSERT_TRUE(GetSslCipher(false, &server_cipher)); |
1014 | 1022 |
1015 ASSERT_EQ(client_cipher, server_cipher); | 1023 ASSERT_EQ(client_cipher, server_cipher); |
1016 ASSERT_EQ(rtc::SSLStreamAdapter::GetDefaultSslCipher( | 1024 ASSERT_EQ( |
1017 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam())), | 1025 rtc::SSLStreamAdapter::GetDefaultSslCipher( |
1018 server_cipher); | 1026 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam())).rfc_name, |
| 1027 server_cipher); |
1019 } | 1028 } |
1020 | 1029 |
1021 // DTLS 1.2 enabled for server only -> DTLS 1.0 will be used. | 1030 // DTLS 1.2 enabled for server only -> DTLS 1.0 will be used. |
1022 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherDtls12Server) { | 1031 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherDtls12Server) { |
1023 MAYBE_SKIP_TEST(HaveDtls); | 1032 MAYBE_SKIP_TEST(HaveDtls); |
1024 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_10); | 1033 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_10); |
1025 TestHandshake(); | 1034 TestHandshake(); |
1026 | 1035 |
1027 std::string client_cipher; | 1036 std::string client_cipher; |
1028 ASSERT_TRUE(GetSslCipher(true, &client_cipher)); | 1037 ASSERT_TRUE(GetSslCipher(true, &client_cipher)); |
1029 std::string server_cipher; | 1038 std::string server_cipher; |
1030 ASSERT_TRUE(GetSslCipher(false, &server_cipher)); | 1039 ASSERT_TRUE(GetSslCipher(false, &server_cipher)); |
1031 | 1040 |
1032 ASSERT_EQ(client_cipher, server_cipher); | 1041 ASSERT_EQ(client_cipher, server_cipher); |
1033 ASSERT_EQ(rtc::SSLStreamAdapter::GetDefaultSslCipher( | 1042 ASSERT_EQ(rtc::SSLStreamAdapter::GetDefaultSslCipher( |
1034 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam())), | 1043 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam())), |
1035 server_cipher); | 1044 server_cipher); |
1036 } | 1045 } |
1037 | 1046 |
1038 INSTANTIATE_TEST_CASE_P(SSLStreamAdapterTestsTLS, | 1047 INSTANTIATE_TEST_CASE_P(SSLStreamAdapterTestsTLS, |
1039 SSLStreamAdapterTestTLS, | 1048 SSLStreamAdapterTestTLS, |
1040 Combine(Values(rtc::KT_RSA, rtc::KT_ECDSA), | 1049 Combine(Values(rtc::KT_RSA, rtc::KT_ECDSA), |
1041 Values(rtc::KT_RSA, rtc::KT_ECDSA))); | 1050 Values(rtc::KT_RSA, rtc::KT_ECDSA))); |
1042 INSTANTIATE_TEST_CASE_P(SSLStreamAdapterTestsDTLS, | 1051 INSTANTIATE_TEST_CASE_P(SSLStreamAdapterTestsDTLS, |
1043 SSLStreamAdapterTestDTLS, | 1052 SSLStreamAdapterTestDTLS, |
1044 Combine(Values(rtc::KT_RSA, rtc::KT_ECDSA), | 1053 Combine(Values(rtc::KT_RSA, rtc::KT_ECDSA), |
1045 Values(rtc::KT_RSA, rtc::KT_ECDSA))); | 1054 Values(rtc::KT_RSA, rtc::KT_ECDSA))); |
OLD | NEW |