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 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 | 933 |
934 int client_cipher; | 934 int client_cipher; |
935 ASSERT_TRUE(GetDtlsSrtpCryptoSuite(true, &client_cipher)); | 935 ASSERT_TRUE(GetDtlsSrtpCryptoSuite(true, &client_cipher)); |
936 int server_cipher; | 936 int server_cipher; |
937 ASSERT_TRUE(GetDtlsSrtpCryptoSuite(false, &server_cipher)); | 937 ASSERT_TRUE(GetDtlsSrtpCryptoSuite(false, &server_cipher)); |
938 | 938 |
939 ASSERT_EQ(client_cipher, server_cipher); | 939 ASSERT_EQ(client_cipher, server_cipher); |
940 ASSERT_EQ(client_cipher, rtc::SRTP_AES128_CM_SHA1_32); | 940 ASSERT_EQ(client_cipher, rtc::SRTP_AES128_CM_SHA1_32); |
941 }; | 941 }; |
942 | 942 |
943 | |
944 // Test DTLS-SRTP with a mismatch -- should not converge | 943 // Test DTLS-SRTP with a mismatch -- should not converge |
945 TEST_P(SSLStreamAdapterTestDTLS, TestDTLSSrtpHighLow) { | 944 TEST_P(SSLStreamAdapterTestDTLS, TestDTLSSrtpHighLow) { |
946 MAYBE_SKIP_TEST(HaveDtlsSrtp); | 945 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
947 std::vector<int> high; | 946 std::vector<int> high; |
948 high.push_back(rtc::SRTP_AES128_CM_SHA1_80); | 947 high.push_back(rtc::SRTP_AES128_CM_SHA1_80); |
949 std::vector<int> low; | 948 std::vector<int> low; |
950 low.push_back(rtc::SRTP_AES128_CM_SHA1_32); | 949 low.push_back(rtc::SRTP_AES128_CM_SHA1_32); |
951 SetDtlsSrtpCryptoSuites(high, true); | 950 SetDtlsSrtpCryptoSuites(high, true); |
952 SetDtlsSrtpCryptoSuites(low, false); | 951 SetDtlsSrtpCryptoSuites(low, false); |
953 TestHandshake(); | 952 TestHandshake(); |
(...skipping 16 matching lines...) Expand all Loading... |
970 | 969 |
971 int client_cipher; | 970 int client_cipher; |
972 ASSERT_TRUE(GetDtlsSrtpCryptoSuite(true, &client_cipher)); | 971 ASSERT_TRUE(GetDtlsSrtpCryptoSuite(true, &client_cipher)); |
973 int server_cipher; | 972 int server_cipher; |
974 ASSERT_TRUE(GetDtlsSrtpCryptoSuite(false, &server_cipher)); | 973 ASSERT_TRUE(GetDtlsSrtpCryptoSuite(false, &server_cipher)); |
975 | 974 |
976 ASSERT_EQ(client_cipher, server_cipher); | 975 ASSERT_EQ(client_cipher, server_cipher); |
977 ASSERT_EQ(client_cipher, rtc::SRTP_AES128_CM_SHA1_80); | 976 ASSERT_EQ(client_cipher, rtc::SRTP_AES128_CM_SHA1_80); |
978 }; | 977 }; |
979 | 978 |
| 979 // Test DTLS-SRTP with all GCM-128 ciphers. |
| 980 TEST_P(SSLStreamAdapterTestDTLS, TestDTLSSrtpGCM128) { |
| 981 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 982 std::vector<int> gcm128; |
| 983 gcm128.push_back(rtc::SRTP_AEAD_AES_128_GCM); |
| 984 SetDtlsSrtpCryptoSuites(gcm128, true); |
| 985 SetDtlsSrtpCryptoSuites(gcm128, false); |
| 986 TestHandshake(); |
| 987 |
| 988 int client_cipher; |
| 989 ASSERT_TRUE(GetDtlsSrtpCryptoSuite(true, &client_cipher)); |
| 990 int server_cipher; |
| 991 ASSERT_TRUE(GetDtlsSrtpCryptoSuite(false, &server_cipher)); |
| 992 |
| 993 ASSERT_EQ(client_cipher, server_cipher); |
| 994 ASSERT_EQ(client_cipher, rtc::SRTP_AEAD_AES_128_GCM); |
| 995 }; |
| 996 |
| 997 // Test DTLS-SRTP with all GCM-256 ciphers. |
| 998 TEST_P(SSLStreamAdapterTestDTLS, TestDTLSSrtpGCM256) { |
| 999 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 1000 std::vector<int> gcm256; |
| 1001 gcm256.push_back(rtc::SRTP_AEAD_AES_256_GCM); |
| 1002 SetDtlsSrtpCryptoSuites(gcm256, true); |
| 1003 SetDtlsSrtpCryptoSuites(gcm256, false); |
| 1004 TestHandshake(); |
| 1005 |
| 1006 int client_cipher; |
| 1007 ASSERT_TRUE(GetDtlsSrtpCryptoSuite(true, &client_cipher)); |
| 1008 int server_cipher; |
| 1009 ASSERT_TRUE(GetDtlsSrtpCryptoSuite(false, &server_cipher)); |
| 1010 |
| 1011 ASSERT_EQ(client_cipher, server_cipher); |
| 1012 ASSERT_EQ(client_cipher, rtc::SRTP_AEAD_AES_256_GCM); |
| 1013 }; |
| 1014 |
| 1015 // Test DTLS-SRTP with mixed GCM-128/-256 ciphers -- should not converge. |
| 1016 TEST_P(SSLStreamAdapterTestDTLS, TestDTLSSrtpGCMMismatch) { |
| 1017 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 1018 std::vector<int> gcm128; |
| 1019 gcm128.push_back(rtc::SRTP_AEAD_AES_128_GCM); |
| 1020 std::vector<int> gcm256; |
| 1021 gcm256.push_back(rtc::SRTP_AEAD_AES_256_GCM); |
| 1022 SetDtlsSrtpCryptoSuites(gcm128, true); |
| 1023 SetDtlsSrtpCryptoSuites(gcm256, false); |
| 1024 TestHandshake(); |
| 1025 |
| 1026 int client_cipher; |
| 1027 ASSERT_FALSE(GetDtlsSrtpCryptoSuite(true, &client_cipher)); |
| 1028 int server_cipher; |
| 1029 ASSERT_FALSE(GetDtlsSrtpCryptoSuite(false, &server_cipher)); |
| 1030 }; |
| 1031 |
| 1032 // Test DTLS-SRTP with both GCM-128/-256 ciphers -- should select GCM-256. |
| 1033 TEST_P(SSLStreamAdapterTestDTLS, TestDTLSSrtpGCMMixed) { |
| 1034 MAYBE_SKIP_TEST(HaveDtlsSrtp); |
| 1035 std::vector<int> gcmBoth; |
| 1036 gcmBoth.push_back(rtc::SRTP_AEAD_AES_256_GCM); |
| 1037 gcmBoth.push_back(rtc::SRTP_AEAD_AES_128_GCM); |
| 1038 SetDtlsSrtpCryptoSuites(gcmBoth, true); |
| 1039 SetDtlsSrtpCryptoSuites(gcmBoth, false); |
| 1040 TestHandshake(); |
| 1041 |
| 1042 int client_cipher; |
| 1043 ASSERT_TRUE(GetDtlsSrtpCryptoSuite(true, &client_cipher)); |
| 1044 int server_cipher; |
| 1045 ASSERT_TRUE(GetDtlsSrtpCryptoSuite(false, &server_cipher)); |
| 1046 |
| 1047 ASSERT_EQ(client_cipher, server_cipher); |
| 1048 ASSERT_EQ(client_cipher, rtc::SRTP_AEAD_AES_256_GCM); |
| 1049 }; |
| 1050 |
| 1051 // Test SRTP cipher suite lengths. |
| 1052 TEST_P(SSLStreamAdapterTestDTLS, TestDTLSSrtpKeyAndSaltLengths) { |
| 1053 int key_len; |
| 1054 int salt_len; |
| 1055 |
| 1056 ASSERT_FALSE( |
| 1057 rtc::GetSrtpKeyAndSaltLengths( |
| 1058 rtc::SRTP_INVALID_CRYPTO_SUITE, &key_len, &salt_len)); |
| 1059 |
| 1060 ASSERT_TRUE( |
| 1061 rtc::GetSrtpKeyAndSaltLengths( |
| 1062 rtc::SRTP_AES128_CM_SHA1_32, &key_len, &salt_len)); |
| 1063 ASSERT_EQ(128/8, key_len); |
| 1064 ASSERT_EQ(112/8, salt_len); |
| 1065 |
| 1066 ASSERT_TRUE( |
| 1067 rtc::GetSrtpKeyAndSaltLengths( |
| 1068 rtc::SRTP_AES128_CM_SHA1_80, &key_len, &salt_len)); |
| 1069 ASSERT_EQ(128/8, key_len); |
| 1070 ASSERT_EQ(112/8, salt_len); |
| 1071 |
| 1072 ASSERT_TRUE( |
| 1073 rtc::GetSrtpKeyAndSaltLengths( |
| 1074 rtc::SRTP_AEAD_AES_128_GCM, &key_len, &salt_len)); |
| 1075 ASSERT_EQ(128/8, key_len); |
| 1076 ASSERT_EQ(96/8, salt_len); |
| 1077 |
| 1078 ASSERT_TRUE( |
| 1079 rtc::GetSrtpKeyAndSaltLengths( |
| 1080 rtc::SRTP_AEAD_AES_256_GCM, &key_len, &salt_len)); |
| 1081 ASSERT_EQ(256/8, key_len); |
| 1082 ASSERT_EQ(96/8, salt_len); |
| 1083 }; |
| 1084 |
980 // Test an exporter | 1085 // Test an exporter |
981 TEST_P(SSLStreamAdapterTestDTLS, TestDTLSExporter) { | 1086 TEST_P(SSLStreamAdapterTestDTLS, TestDTLSExporter) { |
982 MAYBE_SKIP_TEST(HaveExporter); | 1087 MAYBE_SKIP_TEST(HaveExporter); |
983 TestHandshake(); | 1088 TestHandshake(); |
984 unsigned char client_out[20]; | 1089 unsigned char client_out[20]; |
985 unsigned char server_out[20]; | 1090 unsigned char server_out[20]; |
986 | 1091 |
987 bool result; | 1092 bool result; |
988 result = ExportKeyingMaterial(kExporterLabel, | 1093 result = ExportKeyingMaterial(kExporterLabel, |
989 kExporterContext, kExporterContextLen, | 1094 kExporterContext, kExporterContextLen, |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)))); | 1257 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)))); |
1153 INSTANTIATE_TEST_CASE_P( | 1258 INSTANTIATE_TEST_CASE_P( |
1154 SSLStreamAdapterTestsDTLS, | 1259 SSLStreamAdapterTestsDTLS, |
1155 SSLStreamAdapterTestDTLS, | 1260 SSLStreamAdapterTestDTLS, |
1156 Combine(Values(rtc::KeyParams::RSA(1024, 65537), | 1261 Combine(Values(rtc::KeyParams::RSA(1024, 65537), |
1157 rtc::KeyParams::RSA(1152, 65537), | 1262 rtc::KeyParams::RSA(1152, 65537), |
1158 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)), | 1263 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)), |
1159 Values(rtc::KeyParams::RSA(1024, 65537), | 1264 Values(rtc::KeyParams::RSA(1024, 65537), |
1160 rtc::KeyParams::RSA(1152, 65537), | 1265 rtc::KeyParams::RSA(1152, 65537), |
1161 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)))); | 1266 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)))); |
OLD | NEW |