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

Side by Side Diff: webrtc/pc/srtpfilter.h

Issue 2734643002: Revert of Improve testing of SRTP external auth code paths. (Closed)
Patch Set: Created 3 years, 9 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 | « webrtc/pc/externalhmac.cc ('k') | webrtc/pc/srtpfilter.cc » ('j') | 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 * 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
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 external auth is enabled, SRTP will write a dummy auth tag that then 117 #if defined(ENABLE_EXTERNAL_AUTH)
118 // later must get replaced before the packet is sent out. Only supported for
119 // non-GCM cipher suites and can be checked through "IsExternalAuthActive"
120 // if it is actually used. This method is only valid before the RTP params
121 // have been set.
122 void EnableExternalAuth();
123 bool IsExternalAuthEnabled() const;
124
125 // A SRTP filter supports external creation of the auth tag if a non-GCM 118 // A SRTP filter supports external creation of the auth tag if a non-GCM
126 // cipher is used. This method is only valid after the RTP params have 119 // cipher is used. This method is only valid after the RTP params have
127 // been set. 120 // been set.
128 bool IsExternalAuthActive() const; 121 bool IsExternalAuthActive() const;
122 #endif
129 123
130 // Update the silent threshold (in ms) for signaling errors. 124 // Update the silent threshold (in ms) for signaling errors.
131 void set_signal_silent_time(int signal_silent_time_in_ms); 125 void set_signal_silent_time(int signal_silent_time_in_ms);
132 126
133 bool ResetParams(); 127 bool ResetParams();
134 128
135 sigslot::repeater3<uint32_t, Mode, Error> SignalSrtpError; 129 sigslot::repeater3<uint32_t, Mode, Error> SignalSrtpError;
136 130
137 protected: 131 protected:
138 bool ExpectOffer(ContentSource source); 132 bool ExpectOffer(ContentSource source);
(...skipping 29 matching lines...) Expand all
168 ST_RECEIVEDUPDATEDOFFER, 162 ST_RECEIVEDUPDATEDOFFER,
169 // SRTP filter is active but the sent answer is only provisional. 163 // SRTP filter is active but the sent answer is only provisional.
170 // When the final answer is set, the state transitions to ST_ACTIVE or 164 // When the final answer is set, the state transitions to ST_ACTIVE or
171 // ST_INIT. 165 // ST_INIT.
172 ST_SENTPRANSWER, 166 ST_SENTPRANSWER,
173 // SRTP filter is active but the received answer is only provisional. 167 // SRTP filter is active but the received answer is only provisional.
174 // 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
175 // ST_INIT. 169 // ST_INIT.
176 ST_RECEIVEDPRANSWER 170 ST_RECEIVEDPRANSWER
177 }; 171 };
178 State state_ = ST_INIT; 172 State state_;
179 int signal_silent_time_in_ms_ = 0; 173 int signal_silent_time_in_ms_;
180 bool external_auth_enabled_ = false;
181 std::vector<CryptoParams> offer_params_; 174 std::vector<CryptoParams> offer_params_;
182 std::unique_ptr<SrtpSession> send_session_; 175 std::unique_ptr<SrtpSession> send_session_;
183 std::unique_ptr<SrtpSession> recv_session_; 176 std::unique_ptr<SrtpSession> recv_session_;
184 std::unique_ptr<SrtpSession> send_rtcp_session_; 177 std::unique_ptr<SrtpSession> send_rtcp_session_;
185 std::unique_ptr<SrtpSession> recv_rtcp_session_; 178 std::unique_ptr<SrtpSession> recv_rtcp_session_;
186 CryptoParams applied_send_params_; 179 CryptoParams applied_send_params_;
187 CryptoParams applied_recv_params_; 180 CryptoParams applied_recv_params_;
188 }; 181 };
189 182
190 // Class that wraps a libSRTP session. 183 // Class that wraps a libSRTP session.
(...skipping 22 matching lines...) Expand all
213 // Decrypts/verifies an invidiual RTP/RTCP packet. 206 // Decrypts/verifies an invidiual RTP/RTCP packet.
214 // If an HMAC is used, this will decrease the packet size. 207 // If an HMAC is used, this will decrease the packet size.
215 bool UnprotectRtp(void* data, int in_len, int* out_len); 208 bool UnprotectRtp(void* data, int in_len, int* out_len);
216 bool UnprotectRtcp(void* data, int in_len, int* out_len); 209 bool UnprotectRtcp(void* data, int in_len, int* out_len);
217 210
218 // Helper method to get authentication params. 211 // Helper method to get authentication params.
219 bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len); 212 bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len);
220 213
221 int GetSrtpOverhead() const; 214 int GetSrtpOverhead() const;
222 215
223 // If external auth is enabled, SRTP will write a dummy auth tag that then 216 #if defined(ENABLE_EXTERNAL_AUTH)
224 // later must get replaced before the packet is sent out. Only supported for
225 // non-GCM cipher suites and can be checked through "IsExternalAuthActive"
226 // if it is actually used. This method is only valid before the RTP params
227 // have been set.
228 void EnableExternalAuth();
229 bool IsExternalAuthEnabled() const;
230
231 // A SRTP session supports external creation of the auth tag if a non-GCM 217 // A SRTP session supports external creation of the auth tag if a non-GCM
232 // cipher is used. This method is only valid after the RTP params have 218 // cipher is used. This method is only valid after the RTP params have
233 // been set. 219 // been set.
234 bool IsExternalAuthActive() const; 220 bool IsExternalAuthActive() const;
221 #endif
235 222
236 // Update the silent threshold (in ms) for signaling errors. 223 // Update the silent threshold (in ms) for signaling errors.
237 void set_signal_silent_time(int signal_silent_time_in_ms); 224 void set_signal_silent_time(int signal_silent_time_in_ms);
238 225
239 // Calls srtp_shutdown if it's initialized. 226 // Calls srtp_shutdown if it's initialized.
240 static void Terminate(); 227 static void Terminate();
241 228
242 sigslot::repeater3<uint32_t, SrtpFilter::Mode, SrtpFilter::Error> 229 sigslot::repeater3<uint32_t, SrtpFilter::Mode, SrtpFilter::Error>
243 SignalSrtpError; 230 SignalSrtpError;
244 231
245 private: 232 private:
246 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);
247 // Returns send stream current packet index from srtp db. 234 // Returns send stream current packet index from srtp db.
248 bool GetSendStreamPacketIndex(void* data, int in_len, int64_t* index); 235 bool GetSendStreamPacketIndex(void* data, int in_len, int64_t* index);
249 236
250 static bool Init(); 237 static bool Init();
251 void HandleEvent(const srtp_event_data_t* ev); 238 void HandleEvent(const srtp_event_data_t* ev);
252 static void HandleEventThunk(srtp_event_data_t* ev); 239 static void HandleEventThunk(srtp_event_data_t* ev);
253 240
254 rtc::ThreadChecker thread_checker_; 241 rtc::ThreadChecker thread_checker_;
255 srtp_ctx_t_* session_ = nullptr; 242 srtp_ctx_t_* session_ = nullptr;
256 int rtp_auth_tag_len_ = 0; 243 int rtp_auth_tag_len_ = 0;
257 int rtcp_auth_tag_len_ = 0; 244 int rtcp_auth_tag_len_ = 0;
258 std::unique_ptr<SrtpStat> srtp_stat_; 245 std::unique_ptr<SrtpStat> srtp_stat_;
259 static bool inited_; 246 static bool inited_;
260 static rtc::GlobalLockPod lock_; 247 static rtc::GlobalLockPod lock_;
261 int last_send_seq_num_ = -1; 248 int last_send_seq_num_ = -1;
249 #if defined(ENABLE_EXTERNAL_AUTH)
262 bool external_auth_active_ = false; 250 bool external_auth_active_ = false;
263 bool external_auth_enabled_ = false; 251 #endif
264 RTC_DISALLOW_COPY_AND_ASSIGN(SrtpSession); 252 RTC_DISALLOW_COPY_AND_ASSIGN(SrtpSession);
265 }; 253 };
266 254
267 // Class that collects failures of SRTP. 255 // Class that collects failures of SRTP.
268 class SrtpStat { 256 class SrtpStat {
269 public: 257 public:
270 SrtpStat(); 258 SrtpStat();
271 259
272 // Report RTP protection results to the handler. 260 // Report RTP protection results to the handler.
273 void AddProtectRtpResult(uint32_t ssrc, int result); 261 void AddProtectRtpResult(uint32_t ssrc, int result);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 std::map<FailureKey, FailureStat> failures_; 320 std::map<FailureKey, FailureStat> failures_;
333 // Threshold in ms to silent the signaling errors. 321 // Threshold in ms to silent the signaling errors.
334 int signal_silent_time_; 322 int signal_silent_time_;
335 323
336 RTC_DISALLOW_COPY_AND_ASSIGN(SrtpStat); 324 RTC_DISALLOW_COPY_AND_ASSIGN(SrtpStat);
337 }; 325 };
338 326
339 } // namespace cricket 327 } // namespace cricket
340 328
341 #endif // WEBRTC_PC_SRTPFILTER_H_ 329 #endif // WEBRTC_PC_SRTPFILTER_H_
OLDNEW
« no previous file with comments | « webrtc/pc/externalhmac.cc ('k') | webrtc/pc/srtpfilter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698