OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2009 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2009 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 // If an HMAC is used, this will decrease the packet size. | 107 // If an HMAC is used, this will decrease the packet size. |
108 bool UnprotectRtp(void* data, int in_len, int* out_len); | 108 bool UnprotectRtp(void* data, int in_len, int* out_len); |
109 bool UnprotectRtcp(void* data, int in_len, int* out_len); | 109 bool UnprotectRtcp(void* data, int in_len, int* out_len); |
110 | 110 |
111 // Returns rtp auth params from srtp context. | 111 // Returns rtp auth params from srtp context. |
112 bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len); | 112 bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len); |
113 | 113 |
114 // Returns srtp overhead for rtp packets. | 114 // Returns srtp overhead for rtp packets. |
115 bool GetSrtpOverhead(int* srtp_overhead) const; | 115 bool GetSrtpOverhead(int* srtp_overhead) const; |
116 | 116 |
117 #if defined(ENABLE_EXTERNAL_AUTH) | 117 void AllowExternalAuthForTest(bool allow); |
118 | |
119 // External auth is only allowed if ENABLE_EXTERNAL_AUTH is defined or | |
120 // it has been explicitly activated for tests. | |
Taylor Brandstetter
2017/03/03 02:20:34
Is there any comment in general explaining what ex
joachim
2017/03/03 20:42:57
There is a comment in channel.cc (BaseChannel::Sen
| |
121 bool IsExternalAuthAllowed() const; | |
122 | |
118 // A SRTP filter supports external creation of the auth tag if a non-GCM | 123 // A SRTP filter supports external creation of the auth tag if a non-GCM |
119 // cipher is used. This method is only valid after the RTP params have | 124 // cipher is used. This method is only valid after the RTP params have |
120 // been set. | 125 // been set. |
121 bool IsExternalAuthActive() const; | 126 bool IsExternalAuthActive() const; |
122 #endif | |
123 | 127 |
124 // Update the silent threshold (in ms) for signaling errors. | 128 // Update the silent threshold (in ms) for signaling errors. |
125 void set_signal_silent_time(int signal_silent_time_in_ms); | 129 void set_signal_silent_time(int signal_silent_time_in_ms); |
126 | 130 |
127 bool ResetParams(); | 131 bool ResetParams(); |
128 | 132 |
129 sigslot::repeater3<uint32_t, Mode, Error> SignalSrtpError; | 133 sigslot::repeater3<uint32_t, Mode, Error> SignalSrtpError; |
130 | 134 |
131 protected: | 135 protected: |
132 bool ExpectOffer(ContentSource source); | 136 bool ExpectOffer(ContentSource source); |
(...skipping 29 matching lines...) Expand all Loading... | |
162 ST_RECEIVEDUPDATEDOFFER, | 166 ST_RECEIVEDUPDATEDOFFER, |
163 // SRTP filter is active but the sent answer is only provisional. | 167 // SRTP filter is active but the sent answer is only provisional. |
164 // When the final answer is set, the state transitions to ST_ACTIVE or | 168 // When the final answer is set, the state transitions to ST_ACTIVE or |
165 // ST_INIT. | 169 // ST_INIT. |
166 ST_SENTPRANSWER, | 170 ST_SENTPRANSWER, |
167 // SRTP filter is active but the received answer is only provisional. | 171 // SRTP filter is active but the received answer is only provisional. |
168 // When the final answer is set, the state transitions to ST_ACTIVE or | 172 // When the final answer is set, the state transitions to ST_ACTIVE or |
169 // ST_INIT. | 173 // ST_INIT. |
170 ST_RECEIVEDPRANSWER | 174 ST_RECEIVEDPRANSWER |
171 }; | 175 }; |
172 State state_; | 176 State state_ = ST_INIT; |
173 int signal_silent_time_in_ms_; | 177 int signal_silent_time_in_ms_ = 0; |
178 bool external_auth_allowed_ = false; | |
174 std::vector<CryptoParams> offer_params_; | 179 std::vector<CryptoParams> offer_params_; |
175 std::unique_ptr<SrtpSession> send_session_; | 180 std::unique_ptr<SrtpSession> send_session_; |
176 std::unique_ptr<SrtpSession> recv_session_; | 181 std::unique_ptr<SrtpSession> recv_session_; |
177 std::unique_ptr<SrtpSession> send_rtcp_session_; | 182 std::unique_ptr<SrtpSession> send_rtcp_session_; |
178 std::unique_ptr<SrtpSession> recv_rtcp_session_; | 183 std::unique_ptr<SrtpSession> recv_rtcp_session_; |
179 CryptoParams applied_send_params_; | 184 CryptoParams applied_send_params_; |
180 CryptoParams applied_recv_params_; | 185 CryptoParams applied_recv_params_; |
181 }; | 186 }; |
182 | 187 |
183 // Class that wraps a libSRTP session. | 188 // Class that wraps a libSRTP session. |
(...skipping 22 matching lines...) Expand all Loading... | |
206 // Decrypts/verifies an invidiual RTP/RTCP packet. | 211 // Decrypts/verifies an invidiual RTP/RTCP packet. |
207 // If an HMAC is used, this will decrease the packet size. | 212 // If an HMAC is used, this will decrease the packet size. |
208 bool UnprotectRtp(void* data, int in_len, int* out_len); | 213 bool UnprotectRtp(void* data, int in_len, int* out_len); |
209 bool UnprotectRtcp(void* data, int in_len, int* out_len); | 214 bool UnprotectRtcp(void* data, int in_len, int* out_len); |
210 | 215 |
211 // Helper method to get authentication params. | 216 // Helper method to get authentication params. |
212 bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len); | 217 bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len); |
213 | 218 |
214 int GetSrtpOverhead() const; | 219 int GetSrtpOverhead() const; |
215 | 220 |
216 #if defined(ENABLE_EXTERNAL_AUTH) | 221 void AllowExternalAuthForTest(bool allow); |
222 | |
223 // External auth is only allowed if ENABLE_EXTERNAL_AUTH is defined or | |
224 // it has been explicitly activated for tests. | |
225 bool IsExternalAuthAllowed() const; | |
226 | |
217 // A SRTP session supports external creation of the auth tag if a non-GCM | 227 // A SRTP session supports external creation of the auth tag if a non-GCM |
218 // cipher is used. This method is only valid after the RTP params have | 228 // cipher is used. This method is only valid after the RTP params have |
219 // been set. | 229 // been set. |
220 bool IsExternalAuthActive() const; | 230 bool IsExternalAuthActive() const; |
221 #endif | |
222 | 231 |
223 // Update the silent threshold (in ms) for signaling errors. | 232 // Update the silent threshold (in ms) for signaling errors. |
224 void set_signal_silent_time(int signal_silent_time_in_ms); | 233 void set_signal_silent_time(int signal_silent_time_in_ms); |
225 | 234 |
226 // Calls srtp_shutdown if it's initialized. | 235 // Calls srtp_shutdown if it's initialized. |
227 static void Terminate(); | 236 static void Terminate(); |
228 | 237 |
229 sigslot::repeater3<uint32_t, SrtpFilter::Mode, SrtpFilter::Error> | 238 sigslot::repeater3<uint32_t, SrtpFilter::Mode, SrtpFilter::Error> |
230 SignalSrtpError; | 239 SignalSrtpError; |
231 | 240 |
232 private: | 241 private: |
233 bool SetKey(int type, int cs, const uint8_t* key, size_t len); | 242 bool SetKey(int type, int cs, const uint8_t* key, size_t len); |
234 // Returns send stream current packet index from srtp db. | 243 // Returns send stream current packet index from srtp db. |
235 bool GetSendStreamPacketIndex(void* data, int in_len, int64_t* index); | 244 bool GetSendStreamPacketIndex(void* data, int in_len, int64_t* index); |
236 | 245 |
237 static bool Init(); | 246 static bool Init(); |
238 void HandleEvent(const srtp_event_data_t* ev); | 247 void HandleEvent(const srtp_event_data_t* ev); |
239 static void HandleEventThunk(srtp_event_data_t* ev); | 248 static void HandleEventThunk(srtp_event_data_t* ev); |
240 | 249 |
241 rtc::ThreadChecker thread_checker_; | 250 rtc::ThreadChecker thread_checker_; |
242 srtp_ctx_t_* session_ = nullptr; | 251 srtp_ctx_t_* session_ = nullptr; |
243 int rtp_auth_tag_len_ = 0; | 252 int rtp_auth_tag_len_ = 0; |
244 int rtcp_auth_tag_len_ = 0; | 253 int rtcp_auth_tag_len_ = 0; |
245 std::unique_ptr<SrtpStat> srtp_stat_; | 254 std::unique_ptr<SrtpStat> srtp_stat_; |
246 static bool inited_; | 255 static bool inited_; |
247 static rtc::GlobalLockPod lock_; | 256 static rtc::GlobalLockPod lock_; |
248 int last_send_seq_num_ = -1; | 257 int last_send_seq_num_ = -1; |
249 #if defined(ENABLE_EXTERNAL_AUTH) | |
250 bool external_auth_active_ = false; | 258 bool external_auth_active_ = false; |
251 #endif | 259 bool external_auth_allowed_ = false; |
252 RTC_DISALLOW_COPY_AND_ASSIGN(SrtpSession); | 260 RTC_DISALLOW_COPY_AND_ASSIGN(SrtpSession); |
253 }; | 261 }; |
254 | 262 |
255 // Class that collects failures of SRTP. | 263 // Class that collects failures of SRTP. |
256 class SrtpStat { | 264 class SrtpStat { |
257 public: | 265 public: |
258 SrtpStat(); | 266 SrtpStat(); |
259 | 267 |
260 // Report RTP protection results to the handler. | 268 // Report RTP protection results to the handler. |
261 void AddProtectRtpResult(uint32_t ssrc, int result); | 269 void AddProtectRtpResult(uint32_t ssrc, int result); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 std::map<FailureKey, FailureStat> failures_; | 328 std::map<FailureKey, FailureStat> failures_; |
321 // Threshold in ms to silent the signaling errors. | 329 // Threshold in ms to silent the signaling errors. |
322 int signal_silent_time_; | 330 int signal_silent_time_; |
323 | 331 |
324 RTC_DISALLOW_COPY_AND_ASSIGN(SrtpStat); | 332 RTC_DISALLOW_COPY_AND_ASSIGN(SrtpStat); |
325 }; | 333 }; |
326 | 334 |
327 } // namespace cricket | 335 } // namespace cricket |
328 | 336 |
329 #endif // WEBRTC_PC_SRTPFILTER_H_ | 337 #endif // WEBRTC_PC_SRTPFILTER_H_ |
OLD | NEW |