| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 int in_len, | 101 int in_len, |
| 102 int max_len, | 102 int max_len, |
| 103 int* out_len, | 103 int* out_len, |
| 104 int64_t* index); | 104 int64_t* index); |
| 105 bool ProtectRtcp(void* data, int in_len, int max_len, int* out_len); | 105 bool ProtectRtcp(void* data, int in_len, int max_len, int* out_len); |
| 106 // Decrypts/verifies an invidiual RTP/RTCP packet. | 106 // Decrypts/verifies an invidiual RTP/RTCP packet. |
| 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 // A SRTP filter supports external creation of the auth tag if a non-GCM |
| 112 // cipher is used. This method is only valid after the RTP params have |
| 113 // been set. |
| 114 bool AllowExternalAuth(); |
| 115 |
| 116 // Force-disable support for external auth tag creation. This is required |
| 117 // for some tests. |
| 118 void DisableAllowExternalAuthForTests(bool disable_allow_external_auth); |
| 119 |
| 111 // Returns rtp auth params from srtp context. | 120 // Returns rtp auth params from srtp context. |
| 112 bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len); | 121 bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len); |
| 113 | 122 |
| 114 // Returns srtp overhead for rtp packets. | 123 // Returns srtp overhead for rtp packets. |
| 115 bool GetSrtpOverhead(int* srtp_overhead) const; | 124 bool GetSrtpOverhead(int* srtp_overhead) const; |
| 116 | 125 |
| 117 // Update the silent threshold (in ms) for signaling errors. | 126 // Update the silent threshold (in ms) for signaling errors. |
| 118 void set_signal_silent_time(int signal_silent_time_in_ms); | 127 void set_signal_silent_time(int signal_silent_time_in_ms); |
| 119 | 128 |
| 120 bool ResetParams(); | 129 bool ResetParams(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // When the final answer is set, the state transitions to ST_ACTIVE or | 166 // When the final answer is set, the state transitions to ST_ACTIVE or |
| 158 // ST_INIT. | 167 // ST_INIT. |
| 159 ST_SENTPRANSWER, | 168 ST_SENTPRANSWER, |
| 160 // SRTP filter is active but the received answer is only provisional. | 169 // SRTP filter is active but the received answer is only provisional. |
| 161 // When the final answer is set, the state transitions to ST_ACTIVE or | 170 // When the final answer is set, the state transitions to ST_ACTIVE or |
| 162 // ST_INIT. | 171 // ST_INIT. |
| 163 ST_RECEIVEDPRANSWER | 172 ST_RECEIVEDPRANSWER |
| 164 }; | 173 }; |
| 165 State state_; | 174 State state_; |
| 166 int signal_silent_time_in_ms_; | 175 int signal_silent_time_in_ms_; |
| 176 bool force_disable_allow_external_auth_ = false; |
| 167 std::vector<CryptoParams> offer_params_; | 177 std::vector<CryptoParams> offer_params_; |
| 168 std::unique_ptr<SrtpSession> send_session_; | 178 std::unique_ptr<SrtpSession> send_session_; |
| 169 std::unique_ptr<SrtpSession> recv_session_; | 179 std::unique_ptr<SrtpSession> recv_session_; |
| 170 std::unique_ptr<SrtpSession> send_rtcp_session_; | 180 std::unique_ptr<SrtpSession> send_rtcp_session_; |
| 171 std::unique_ptr<SrtpSession> recv_rtcp_session_; | 181 std::unique_ptr<SrtpSession> recv_rtcp_session_; |
| 172 CryptoParams applied_send_params_; | 182 CryptoParams applied_send_params_; |
| 173 CryptoParams applied_recv_params_; | 183 CryptoParams applied_recv_params_; |
| 174 }; | 184 }; |
| 175 | 185 |
| 176 // Class that wraps a libSRTP session. | 186 // Class that wraps a libSRTP session. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 194 int in_len, | 204 int in_len, |
| 195 int max_len, | 205 int max_len, |
| 196 int* out_len, | 206 int* out_len, |
| 197 int64_t* index); | 207 int64_t* index); |
| 198 bool ProtectRtcp(void* data, int in_len, int max_len, int* out_len); | 208 bool ProtectRtcp(void* data, int in_len, int max_len, int* out_len); |
| 199 // Decrypts/verifies an invidiual RTP/RTCP packet. | 209 // Decrypts/verifies an invidiual RTP/RTCP packet. |
| 200 // If an HMAC is used, this will decrease the packet size. | 210 // If an HMAC is used, this will decrease the packet size. |
| 201 bool UnprotectRtp(void* data, int in_len, int* out_len); | 211 bool UnprotectRtp(void* data, int in_len, int* out_len); |
| 202 bool UnprotectRtcp(void* data, int in_len, int* out_len); | 212 bool UnprotectRtcp(void* data, int in_len, int* out_len); |
| 203 | 213 |
| 214 bool AllowExternalAuth(); |
| 215 |
| 216 void DisableAllowExternalAuthForTests(bool disable_allow_external_auth); |
| 217 |
| 204 // Helper method to get authentication params. | 218 // Helper method to get authentication params. |
| 205 bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len); | 219 bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len); |
| 206 | 220 |
| 207 int GetSrtpOverhead() const; | 221 int GetSrtpOverhead() const; |
| 208 | 222 |
| 209 // Update the silent threshold (in ms) for signaling errors. | 223 // Update the silent threshold (in ms) for signaling errors. |
| 210 void set_signal_silent_time(int signal_silent_time_in_ms); | 224 void set_signal_silent_time(int signal_silent_time_in_ms); |
| 211 | 225 |
| 212 // Calls srtp_shutdown if it's initialized. | 226 // Calls srtp_shutdown if it's initialized. |
| 213 static void Terminate(); | 227 static void Terminate(); |
| 214 | 228 |
| 215 sigslot::repeater3<uint32_t, SrtpFilter::Mode, SrtpFilter::Error> | 229 sigslot::repeater3<uint32_t, SrtpFilter::Mode, SrtpFilter::Error> |
| 216 SignalSrtpError; | 230 SignalSrtpError; |
| 217 | 231 |
| 218 private: | 232 private: |
| 219 bool SetKey(int type, int cs, const uint8_t* key, size_t len); | 233 bool SetKey(int type, int cs, const uint8_t* key, size_t len); |
| 220 // Returns send stream current packet index from srtp db. | 234 // Returns send stream current packet index from srtp db. |
| 221 bool GetSendStreamPacketIndex(void* data, int in_len, int64_t* index); | 235 bool GetSendStreamPacketIndex(void* data, int in_len, int64_t* index); |
| 222 | 236 |
| 223 static bool Init(); | 237 static bool Init(); |
| 224 void HandleEvent(const srtp_event_data_t* ev); | 238 void HandleEvent(const srtp_event_data_t* ev); |
| 225 static void HandleEventThunk(srtp_event_data_t* ev); | 239 static void HandleEventThunk(srtp_event_data_t* ev); |
| 226 | 240 |
| 227 rtc::ThreadChecker thread_checker_; | 241 rtc::ThreadChecker thread_checker_; |
| 228 srtp_ctx_t_* session_; | 242 srtp_ctx_t_* session_ = nullptr; |
| 229 int rtp_auth_tag_len_; | 243 int rtp_auth_tag_len_ = 0; |
| 230 int rtcp_auth_tag_len_; | 244 int rtcp_auth_tag_len_ = 0; |
| 231 std::unique_ptr<SrtpStat> srtp_stat_; | 245 std::unique_ptr<SrtpStat> srtp_stat_; |
| 232 static bool inited_; | 246 static bool inited_; |
| 233 static rtc::GlobalLockPod lock_; | 247 static rtc::GlobalLockPod lock_; |
| 234 int last_send_seq_num_; | 248 int last_send_seq_num_ = -1; |
| 249 bool allow_external_auth_ = false; |
| 250 bool force_disable_allow_external_auth_ = false; |
| 235 RTC_DISALLOW_COPY_AND_ASSIGN(SrtpSession); | 251 RTC_DISALLOW_COPY_AND_ASSIGN(SrtpSession); |
| 236 }; | 252 }; |
| 237 | 253 |
| 238 // Class that collects failures of SRTP. | 254 // Class that collects failures of SRTP. |
| 239 class SrtpStat { | 255 class SrtpStat { |
| 240 public: | 256 public: |
| 241 SrtpStat(); | 257 SrtpStat(); |
| 242 | 258 |
| 243 // Report RTP protection results to the handler. | 259 // Report RTP protection results to the handler. |
| 244 void AddProtectRtpResult(uint32_t ssrc, int result); | 260 void AddProtectRtpResult(uint32_t ssrc, int result); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 std::map<FailureKey, FailureStat> failures_; | 319 std::map<FailureKey, FailureStat> failures_; |
| 304 // Threshold in ms to silent the signaling errors. | 320 // Threshold in ms to silent the signaling errors. |
| 305 int signal_silent_time_; | 321 int signal_silent_time_; |
| 306 | 322 |
| 307 RTC_DISALLOW_COPY_AND_ASSIGN(SrtpStat); | 323 RTC_DISALLOW_COPY_AND_ASSIGN(SrtpStat); |
| 308 }; | 324 }; |
| 309 | 325 |
| 310 } // namespace cricket | 326 } // namespace cricket |
| 311 | 327 |
| 312 #endif // WEBRTC_PC_SRTPFILTER_H_ | 328 #endif // WEBRTC_PC_SRTPFILTER_H_ |
| OLD | NEW |