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

Side by Side Diff: talk/app/webrtc/webrtcsession.cc

Issue 1337673002: Change WebRTC SslCipher to be exposed as number only. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « talk/app/webrtc/umametrics.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 const char kSdpWithoutIceUfragPwd[] = 81 const char kSdpWithoutIceUfragPwd[] =
82 "Called with SDP without ice-ufrag and ice-pwd."; 82 "Called with SDP without ice-ufrag and ice-pwd.";
83 const char kSessionError[] = "Session error code: "; 83 const char kSessionError[] = "Session error code: ";
84 const char kSessionErrorDesc[] = "Session error description: "; 84 const char kSessionErrorDesc[] = "Session error description: ";
85 const char kDtlsSetupFailureRtp[] = 85 const char kDtlsSetupFailureRtp[] =
86 "Couldn't set up DTLS-SRTP on RTP channel."; 86 "Couldn't set up DTLS-SRTP on RTP channel.";
87 const char kDtlsSetupFailureRtcp[] = 87 const char kDtlsSetupFailureRtcp[] =
88 "Couldn't set up DTLS-SRTP on RTCP channel."; 88 "Couldn't set up DTLS-SRTP on RTCP channel.";
89 const int kMaxUnsignalledRecvStreams = 20; 89 const int kMaxUnsignalledRecvStreams = 20;
90 90
91 SrtpCipherType GetSrtpCipherType(const std::string& cipher) {
92 if (cipher == "AES_CM_128_HMAC_SHA1_32")
93 return SrtpCipherType_AES_CM_128_HMAC_SHA1_32;
94 if (cipher == "AES_CM_128_HMAC_SHA1_80")
95 return SrtpCipherType_AES_CM_128_HMAC_SHA1_80;
Ryan Sleevi 2015/09/22 21:42:15 For what it's worth, this registration is also cov
guoweis_webrtc 2015/09/23 06:46:16 Even though these are also defined in IANA, do you
96 return SrtpCipherType_Unknown;
97 }
98
99 SslCipherType GetSslCipherType(const std::string& cipher) {
100 // TLS v1.0 ciphersuites from RFC2246.
101 if (cipher == "TLS_RSA_RC4_128_SHA")
Ryan Sleevi 2015/09/22 21:42:15 As mentioned by davidben@, you should not design y
102 return SslCipherType_TLS_RSA_RC4_128_SHA;
103 if (cipher == "TLS_RSA_WITH_3DES_EDE_CBC_SHA")
104 return SslCipherType_TLS_RSA_WITH_3DES_EDE_CBC_SHA;
105
106 // AES ciphersuites from RFC3268.
107 if (cipher == "TLS_RSA_WITH_AES_128_CBC_SHA")
108 return SslCipherType_TLS_RSA_WITH_AES_128_CBC_SHA;
109 if (cipher == "TLS_DHE_RSA_WITH_AES_128_CBC_SHA")
110 return SslCipherType_TLS_DHE_RSA_WITH_AES_128_CBC_SHA;
111 if (cipher == "TLS_RSA_WITH_AES_256_CBC_SHA")
112 return SslCipherType_TLS_RSA_WITH_AES_256_CBC_SHA;
113 if (cipher == "TLS_DHE_RSA_WITH_AES_256_CBC_SHA")
114 return SslCipherType_TLS_DHE_RSA_WITH_AES_256_CBC_SHA;
115
116 // ECC ciphersuites from RFC4492.
117 if (cipher == "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA")
118 return SslCipherType_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA;
119 if (cipher == "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA")
120 return SslCipherType_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA;
121 if (cipher == "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA")
122 return SslCipherType_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA;
123 if (cipher == "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA")
124 return SslCipherType_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA;
125
126 if (cipher == "TLS_ECDHE_RSA_WITH_RC4_128_SHA")
127 return SslCipherType_TLS_ECDHE_RSA_WITH_RC4_128_SHA;
128 if (cipher == "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA")
129 return SslCipherType_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA;
130 if (cipher == "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA")
131 return SslCipherType_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA;
132 if (cipher == "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA")
133 return SslCipherType_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA;
134
135 // TLS v1.2 ciphersuites.
136 if (cipher == "TLS_RSA_WITH_AES_128_CBC_SHA256")
137 return SslCipherType_TLS_RSA_WITH_AES_128_CBC_SHA256;
138 if (cipher == "TLS_RSA_WITH_AES_256_CBC_SHA256")
139 return SslCipherType_TLS_RSA_WITH_AES_256_CBC_SHA256;
140 if (cipher == "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256")
141 return SslCipherType_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256;
142 if (cipher == "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256")
143 return SslCipherType_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256;
144
145 // TLS v1.2 GCM ciphersuites from RFC5288.
146 if (cipher == "TLS_RSA_WITH_AES_128_GCM_SHA256")
147 return SslCipherType_TLS_RSA_WITH_AES_128_GCM_SHA256;
148 if (cipher == "TLS_RSA_WITH_AES_256_GCM_SHA384")
149 return SslCipherType_TLS_RSA_WITH_AES_256_GCM_SHA384;
150 if (cipher == "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256")
151 return SslCipherType_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256;
152 if (cipher == "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384")
153 return SslCipherType_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384;
154 if (cipher == "TLS_DH_RSA_WITH_AES_128_GCM_SHA256")
155 return SslCipherType_TLS_DH_RSA_WITH_AES_128_GCM_SHA256;
156 if (cipher == "TLS_DH_RSA_WITH_AES_256_GCM_SHA384")
157 return SslCipherType_TLS_DH_RSA_WITH_AES_256_GCM_SHA384;
158
159 // ECDH HMAC based ciphersuites from RFC5289.
160 if (cipher == "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256")
161 return SslCipherType_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256;
162 if (cipher == "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384")
163 return SslCipherType_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384;
164 if (cipher == "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256")
165 return SslCipherType_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256;
166 if (cipher == "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384")
167 return SslCipherType_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384;
168
169 // ECDH GCM based ciphersuites from RFC5289.
170 if (cipher == "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256")
171 return SslCipherType_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256;
172 if (cipher == "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384")
173 return SslCipherType_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384;
174 if (cipher == "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256")
175 return SslCipherType_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256;
176 if (cipher == "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384")
177 return SslCipherType_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384;
178 if (cipher == "TLS_RSA_RC4_128_SHA")
179 return SslCipherType_TLS_RSA_RC4_128_SHA;
180
181 return SslCipherType_Unknown;
182 }
183
91 IceCandidatePairType GetIceCandidatePairCounter( 184 IceCandidatePairType GetIceCandidatePairCounter(
92 const cricket::Candidate& local, 185 const cricket::Candidate& local,
93 const cricket::Candidate& remote) { 186 const cricket::Candidate& remote) {
94 const auto& l = local.type(); 187 const auto& l = local.type();
95 const auto& r = remote.type(); 188 const auto& r = remote.type();
96 const auto& host = LOCAL_PORT_TYPE; 189 const auto& host = LOCAL_PORT_TYPE;
97 const auto& srflx = STUN_PORT_TYPE; 190 const auto& srflx = STUN_PORT_TYPE;
98 const auto& relay = RELAY_PORT_TYPE; 191 const auto& relay = RELAY_PORT_TYPE;
99 const auto& prflx = PRFLX_PORT_TYPE; 192 const auto& prflx = PRFLX_PORT_TYPE;
100 if (l == host && r == host) { 193 if (l == host && r == host) {
(...skipping 1946 matching lines...) Expand 10 before | Expand all | Expand 10 after
2047 kPeerConnectionAddressFamilyCounter_Max); 2140 kPeerConnectionAddressFamilyCounter_Max);
2048 } else { 2141 } else {
2049 RTC_CHECK(0); 2142 RTC_CHECK(0);
2050 } 2143 }
2051 2144
2052 return; 2145 return;
2053 } 2146 }
2054 } 2147 }
2055 } 2148 }
2056 2149
2150 // Since this is reported in the first OnTransportCompleted, in the non-bundled
2151 // case, we might not be reporting anything other than the first completed
2152 // channel.
2057 void WebRtcSession::ReportNegotiatedCiphers( 2153 void WebRtcSession::ReportNegotiatedCiphers(
2058 const cricket::TransportStats& stats) { 2154 const cricket::TransportStats& stats) {
2059 RTC_DCHECK(metrics_observer_ != NULL); 2155 RTC_DCHECK(metrics_observer_ != NULL);
2060 if (!dtls_enabled_ || stats.channel_stats.empty()) { 2156 if (!dtls_enabled_ || stats.channel_stats.empty()) {
2061 return; 2157 return;
2062 } 2158 }
2063 2159
2064 const std::string& srtp_cipher = stats.channel_stats[0].srtp_cipher; 2160 const std::string& srtp_cipher = stats.channel_stats[0].srtp_cipher;
2065 const std::string& ssl_cipher = stats.channel_stats[0].ssl_cipher; 2161 const std::string& ssl_cipher = stats.channel_stats[0].ssl_cipher;
2066 if (srtp_cipher.empty() && ssl_cipher.empty()) { 2162 if (srtp_cipher.empty() && ssl_cipher.empty()) {
2067 return; 2163 return;
2068 } 2164 }
2069 2165
2070 PeerConnectionMetricsName srtp_name; 2166 PeerConnectionEnumCounterType srtp_counter_type;
2071 PeerConnectionMetricsName ssl_name; 2167 PeerConnectionEnumCounterType ssl_counter_type;
2072 if (stats.content_name == cricket::CN_AUDIO) { 2168 if (stats.content_name == cricket::CN_AUDIO) {
2073 srtp_name = kAudioSrtpCipher; 2169 srtp_counter_type = kEnumCounterAudioSrtpCipher;
2074 ssl_name = kAudioSslCipher; 2170 ssl_counter_type = kEnumCounterAudioSslCipher;
2075 } else if (stats.content_name == cricket::CN_VIDEO) { 2171 } else if (stats.content_name == cricket::CN_VIDEO) {
2076 srtp_name = kVideoSrtpCipher; 2172 srtp_counter_type = kEnumCounterVideoSrtpCipher;
2077 ssl_name = kVideoSslCipher; 2173 ssl_counter_type = kEnumCounterVideoSslCipher;
2078 } else if (stats.content_name == cricket::CN_DATA) { 2174 } else if (stats.content_name == cricket::CN_DATA) {
2079 srtp_name = kDataSrtpCipher; 2175 srtp_counter_type = kEnumCounterDataSrtpCipher;
2080 ssl_name = kDataSslCipher; 2176 ssl_counter_type = kEnumCounterDataSslCipher;
2081 } else { 2177 } else {
2082 RTC_NOTREACHED(); 2178 RTC_NOTREACHED();
2083 return; 2179 return;
2084 } 2180 }
2085 2181
2086 if (!srtp_cipher.empty()) { 2182 if (!srtp_cipher.empty()) {
2087 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); 2183 metrics_observer_->IncrementEnumCounter(
2184 srtp_counter_type, GetSrtpCipherType(srtp_cipher), SrtpCipherType_Max);
2088 } 2185 }
2089 if (!ssl_cipher.empty()) { 2186 if (!ssl_cipher.empty()) {
2090 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); 2187 metrics_observer_->IncrementEnumCounter(
2188 ssl_counter_type, GetSslCipherType(ssl_cipher), SslCipherType_Max);
2091 } 2189 }
2092 } 2190 }
2093 2191
2094 } // namespace webrtc 2192 } // namespace webrtc
OLDNEW
« no previous file with comments | « talk/app/webrtc/umametrics.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698