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 |
11 #include "webrtc/pc/srtpfilter.h" | 11 #include "webrtc/pc/srtpfilter.h" |
12 | 12 |
13 #include <string.h> | 13 #include <string.h> |
14 | 14 |
15 #include <algorithm> | 15 #include <algorithm> |
16 | 16 |
17 #include "webrtc/base/base64.h" | 17 #include "webrtc/base/base64.h" |
18 #include "webrtc/base/buffer.h" | 18 #include "webrtc/base/buffer.h" |
19 #include "webrtc/base/byteorder.h" | 19 #include "webrtc/base/byteorder.h" |
20 #include "webrtc/base/checks.h" | 20 #include "webrtc/base/checks.h" |
21 #include "webrtc/base/common.h" | 21 #include "webrtc/base/common.h" |
22 #include "webrtc/base/logging.h" | 22 #include "webrtc/base/logging.h" |
23 #include "webrtc/base/stringencode.h" | 23 #include "webrtc/base/stringencode.h" |
24 #include "webrtc/base/timeutils.h" | 24 #include "webrtc/base/timeutils.h" |
25 #include "webrtc/media/base/rtputils.h" | 25 #include "webrtc/media/base/rtputils.h" |
26 #include "webrtc/pc/externalhmac.h" | 26 #include "webrtc/pc/externalhmac.h" |
27 | 27 |
28 // Enable this line to turn on SRTP debugging | |
29 // #define SRTP_DEBUG | |
30 | |
31 #ifdef HAVE_SRTP | 28 #ifdef HAVE_SRTP |
32 extern "C" { | 29 extern "C" { |
33 #ifdef SRTP_RELATIVE_PATH | 30 #ifdef SRTP_RELATIVE_PATH |
34 #include "srtp.h" // NOLINT | 31 #include "srtp.h" // NOLINT |
35 #include "srtp_priv.h" // NOLINT | 32 #include "srtp_priv.h" // NOLINT |
36 #else | 33 #else |
37 #include "third_party/libsrtp/include/srtp.h" | 34 #include "third_party/libsrtp/include/srtp.h" |
38 #include "third_party/libsrtp/include/srtp_priv.h" | 35 #include "third_party/libsrtp/include/srtp_priv.h" |
39 #endif // SRTP_RELATIVE_PATH | 36 #endif // SRTP_RELATIVE_PATH |
40 } | 37 } |
41 | |
42 #if !defined(NDEBUG) | |
43 extern "C" srtp_debug_module_t mod_srtp; | |
44 extern "C" srtp_debug_module_t mod_auth; | |
45 extern "C" srtp_debug_module_t mod_cipher; | |
46 extern "C" srtp_debug_module_t mod_stat; | |
47 extern "C" srtp_debug_module_t mod_alloc; | |
48 extern "C" srtp_debug_module_t mod_aes_icm; | |
49 extern "C" srtp_debug_module_t mod_aes_hmac; | |
50 #endif | |
51 #endif // HAVE_SRTP | 38 #endif // HAVE_SRTP |
52 | 39 |
53 namespace cricket { | 40 namespace cricket { |
54 | 41 |
55 #ifndef HAVE_SRTP | 42 #ifndef HAVE_SRTP |
56 | 43 |
57 // This helper function is used on systems that don't (yet) have SRTP, | 44 // This helper function is used on systems that don't (yet) have SRTP, |
58 // to log that the functions that require it won't do anything. | 45 // to log that the functions that require it won't do anything. |
59 namespace { | 46 namespace { |
60 bool SrtpNotAvailable(const char *func) { | 47 bool SrtpNotAvailable(const char *func) { |
61 LOG(LS_ERROR) << func << ": SRTP is not available on your system."; | 48 LOG(LS_ERROR) << func << ": SRTP is not available on your system."; |
62 return false; | 49 return false; |
63 } | 50 } |
64 } // anonymous namespace | 51 } // anonymous namespace |
65 | 52 |
66 #endif // !HAVE_SRTP | 53 #endif // !HAVE_SRTP |
67 | 54 |
68 void EnableSrtpDebugging() { | |
69 #ifdef HAVE_SRTP | |
70 #if !defined(NDEBUG) | |
71 debug_on(mod_srtp); | |
72 debug_on(mod_auth); | |
73 debug_on(mod_cipher); | |
74 debug_on(mod_stat); | |
75 debug_on(mod_alloc); | |
76 debug_on(mod_aes_icm); | |
77 // debug_on(mod_aes_cbc); | |
78 // debug_on(mod_hmac); | |
79 #endif | |
80 #endif // HAVE_SRTP | |
81 } | |
82 | |
83 // NOTE: This is called from ChannelManager D'tor. | 55 // NOTE: This is called from ChannelManager D'tor. |
84 void ShutdownSrtp() { | 56 void ShutdownSrtp() { |
85 #ifdef HAVE_SRTP | 57 #ifdef HAVE_SRTP |
86 // If srtp_dealloc is not executed then this will clear all existing sessions. | 58 // If srtp_dealloc is not executed then this will clear all existing sessions. |
87 // This should be called when application is shutting down. | 59 // This should be called when application is shutting down. |
88 SrtpSession::Terminate(); | 60 SrtpSession::Terminate(); |
89 #endif | 61 #endif |
90 } | 62 } |
91 | 63 |
92 SrtpFilter::SrtpFilter() | 64 SrtpFilter::SrtpFilter() |
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 SrtpNotAvailable(__FUNCTION__); | 933 SrtpNotAvailable(__FUNCTION__); |
962 } | 934 } |
963 | 935 |
964 void SrtpStat::HandleSrtpResult(const SrtpStat::FailureKey& key) { | 936 void SrtpStat::HandleSrtpResult(const SrtpStat::FailureKey& key) { |
965 SrtpNotAvailable(__FUNCTION__); | 937 SrtpNotAvailable(__FUNCTION__); |
966 } | 938 } |
967 | 939 |
968 #endif // HAVE_SRTP | 940 #endif // HAVE_SRTP |
969 | 941 |
970 } // namespace cricket | 942 } // namespace cricket |
OLD | NEW |