OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2009 Google Inc. | 3 * Copyright 2009 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // Indicates which crypto algorithms and keys were contained in the answer. | 97 // Indicates which crypto algorithms and keys were contained in the answer. |
98 // answer_params should contain the negotiated parameters, which may be none, | 98 // answer_params should contain the negotiated parameters, which may be none, |
99 // if crypto was not desired or could not be negotiated (and not required). | 99 // if crypto was not desired or could not be negotiated (and not required). |
100 // This must be called after SetOffer. If crypto negotiation completes | 100 // This must be called after SetOffer. If crypto negotiation completes |
101 // successfully, this will advance the filter to the active state. | 101 // successfully, this will advance the filter to the active state. |
102 bool SetAnswer(const std::vector<CryptoParams>& answer_params, | 102 bool SetAnswer(const std::vector<CryptoParams>& answer_params, |
103 ContentSource source); | 103 ContentSource source); |
104 | 104 |
105 // Just set up both sets of keys directly. | 105 // Just set up both sets of keys directly. |
106 // Used with DTLS-SRTP. | 106 // Used with DTLS-SRTP. |
107 bool SetRtpParams(const std::string& send_cs, | 107 bool SetRtpParams(int send_cs, |
108 const uint8_t* send_key, | 108 const uint8_t* send_key, |
109 int send_key_len, | 109 int send_key_len, |
110 const std::string& recv_cs, | 110 int recv_cs, |
111 const uint8_t* recv_key, | 111 const uint8_t* recv_key, |
112 int recv_key_len); | 112 int recv_key_len); |
113 bool SetRtcpParams(const std::string& send_cs, | 113 bool SetRtcpParams(int send_cs, |
114 const uint8_t* send_key, | 114 const uint8_t* send_key, |
115 int send_key_len, | 115 int send_key_len, |
116 const std::string& recv_cs, | 116 int recv_cs, |
117 const uint8_t* recv_key, | 117 const uint8_t* recv_key, |
118 int recv_key_len); | 118 int recv_key_len); |
119 | 119 |
120 // Encrypts/signs an individual RTP/RTCP packet, in-place. | 120 // Encrypts/signs an individual RTP/RTCP packet, in-place. |
121 // If an HMAC is used, this will increase the packet size. | 121 // If an HMAC is used, this will increase the packet size. |
122 bool ProtectRtp(void* data, int in_len, int max_len, int* out_len); | 122 bool ProtectRtp(void* data, int in_len, int max_len, int* out_len); |
123 // Overloaded version, outputs packet index. | 123 // Overloaded version, outputs packet index. |
124 bool ProtectRtp(void* data, | 124 bool ProtectRtp(void* data, |
125 int in_len, | 125 int in_len, |
126 int max_len, | 126 int max_len, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 }; | 192 }; |
193 | 193 |
194 // Class that wraps a libSRTP session. | 194 // Class that wraps a libSRTP session. |
195 class SrtpSession { | 195 class SrtpSession { |
196 public: | 196 public: |
197 SrtpSession(); | 197 SrtpSession(); |
198 ~SrtpSession(); | 198 ~SrtpSession(); |
199 | 199 |
200 // Configures the session for sending data using the specified | 200 // Configures the session for sending data using the specified |
201 // cipher-suite and key. Receiving must be done by a separate session. | 201 // cipher-suite and key. Receiving must be done by a separate session. |
202 bool SetSend(const std::string& cs, const uint8_t* key, int len); | 202 bool SetSend(int cs, const uint8_t* key, int len); |
203 // Configures the session for receiving data using the specified | 203 // Configures the session for receiving data using the specified |
204 // cipher-suite and key. Sending must be done by a separate session. | 204 // cipher-suite and key. Sending must be done by a separate session. |
205 bool SetRecv(const std::string& cs, const uint8_t* key, int len); | 205 bool SetRecv(int cs, const uint8_t* key, int len); |
206 | 206 |
207 // Encrypts/signs an individual RTP/RTCP packet, in-place. | 207 // Encrypts/signs an individual RTP/RTCP packet, in-place. |
208 // If an HMAC is used, this will increase the packet size. | 208 // If an HMAC is used, this will increase the packet size. |
209 bool ProtectRtp(void* data, int in_len, int max_len, int* out_len); | 209 bool ProtectRtp(void* data, int in_len, int max_len, int* out_len); |
210 // Overloaded version, outputs packet index. | 210 // Overloaded version, outputs packet index. |
211 bool ProtectRtp(void* data, | 211 bool ProtectRtp(void* data, |
212 int in_len, | 212 int in_len, |
213 int max_len, | 213 int max_len, |
214 int* out_len, | 214 int* out_len, |
215 int64_t* index); | 215 int64_t* index); |
216 bool ProtectRtcp(void* data, int in_len, int max_len, int* out_len); | 216 bool ProtectRtcp(void* data, int in_len, int max_len, int* out_len); |
217 // Decrypts/verifies an invidiual RTP/RTCP packet. | 217 // Decrypts/verifies an invidiual RTP/RTCP packet. |
218 // If an HMAC is used, this will decrease the packet size. | 218 // If an HMAC is used, this will decrease the packet size. |
219 bool UnprotectRtp(void* data, int in_len, int* out_len); | 219 bool UnprotectRtp(void* data, int in_len, int* out_len); |
220 bool UnprotectRtcp(void* data, int in_len, int* out_len); | 220 bool UnprotectRtcp(void* data, int in_len, int* out_len); |
221 | 221 |
222 // Helper method to get authentication params. | 222 // Helper method to get authentication params. |
223 bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len); | 223 bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len); |
224 | 224 |
225 // Update the silent threshold (in ms) for signaling errors. | 225 // Update the silent threshold (in ms) for signaling errors. |
226 void set_signal_silent_time(uint32_t signal_silent_time_in_ms); | 226 void set_signal_silent_time(uint32_t signal_silent_time_in_ms); |
227 | 227 |
228 // Calls srtp_shutdown if it's initialized. | 228 // Calls srtp_shutdown if it's initialized. |
229 static void Terminate(); | 229 static void Terminate(); |
230 | 230 |
231 sigslot::repeater3<uint32_t, SrtpFilter::Mode, SrtpFilter::Error> | 231 sigslot::repeater3<uint32_t, SrtpFilter::Mode, SrtpFilter::Error> |
232 SignalSrtpError; | 232 SignalSrtpError; |
233 | 233 |
234 private: | 234 private: |
235 bool SetKey(int type, const std::string& cs, const uint8_t* key, int len); | 235 bool SetKey(int type, int cs, const uint8_t* key, int len); |
236 // Returns send stream current packet index from srtp db. | 236 // Returns send stream current packet index from srtp db. |
237 bool GetSendStreamPacketIndex(void* data, int in_len, int64_t* index); | 237 bool GetSendStreamPacketIndex(void* data, int in_len, int64_t* index); |
238 | 238 |
239 static bool Init(); | 239 static bool Init(); |
240 void HandleEvent(const srtp_event_data_t* ev); | 240 void HandleEvent(const srtp_event_data_t* ev); |
241 static void HandleEventThunk(srtp_event_data_t* ev); | 241 static void HandleEventThunk(srtp_event_data_t* ev); |
242 | 242 |
243 static std::list<SrtpSession*>* sessions(); | 243 static std::list<SrtpSession*>* sessions(); |
244 | 244 |
245 srtp_ctx_t* session_; | 245 srtp_ctx_t* session_; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 std::map<FailureKey, FailureStat> failures_; | 320 std::map<FailureKey, FailureStat> failures_; |
321 // Threshold in ms to silent the signaling errors. | 321 // Threshold in ms to silent the signaling errors. |
322 uint32_t signal_silent_time_; | 322 uint32_t signal_silent_time_; |
323 | 323 |
324 RTC_DISALLOW_COPY_AND_ASSIGN(SrtpStat); | 324 RTC_DISALLOW_COPY_AND_ASSIGN(SrtpStat); |
325 }; | 325 }; |
326 | 326 |
327 } // namespace cricket | 327 } // namespace cricket |
328 | 328 |
329 #endif // TALK_SESSION_MEDIA_SRTPFILTER_H_ | 329 #endif // TALK_SESSION_MEDIA_SRTPFILTER_H_ |
OLD | NEW |