OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2014 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 12 matching lines...) Expand all Loading... |
23 // integer, e.g. SRTP_HMAC_SHA1 is 3. Using authentication ids, the | 23 // integer, e.g. SRTP_HMAC_SHA1 is 3. Using authentication ids, the |
24 // application can plug any desired authentication modules into libsrtp. | 24 // application can plug any desired authentication modules into libsrtp. |
25 // libsrtp also provides a mechanism to select different auth functions for | 25 // libsrtp also provides a mechanism to select different auth functions for |
26 // individual streams. This can be done by setting the right value in | 26 // individual streams. This can be done by setting the right value in |
27 // the auth_type of srtp_policy_t. The application must first register auth | 27 // the auth_type of srtp_policy_t. The application must first register auth |
28 // functions and the corresponding authentication id using | 28 // functions and the corresponding authentication id using |
29 // crypto_kernel_replace_auth_type function. | 29 // crypto_kernel_replace_auth_type function. |
30 | 30 |
31 #include "webrtc/base/basictypes.h" | 31 #include "webrtc/base/basictypes.h" |
32 #ifdef HAVE_SRTP | 32 #ifdef HAVE_SRTP |
33 extern "C" { | |
34 #ifdef SRTP_RELATIVE_PATH | |
35 #include "auth.h" // NOLINT | |
36 #else | |
37 #include "third_party/libsrtp/crypto/include/auth.h" | 33 #include "third_party/libsrtp/crypto/include/auth.h" |
38 #endif // SRTP_RELATIVE_PATH | |
39 } | |
40 #endif // HAVE_SRTP | 34 #endif // HAVE_SRTP |
41 | 35 |
42 #if defined(HAVE_SRTP) && !defined(SRTP_HMAC_SHA1) | |
43 // Include compatibility shims to compile against libsrtp 1.x. | |
44 // TODO(mattdr): Remove once Chromium uses libsrtp 2. | |
45 | |
46 // Remember that the definition of SRTP_HMAC_SHA1 is synthetic. | |
47 #define COMPILING_AGAINST_LIBSRTP1 1 | |
48 | |
49 #define SRTP_HMAC_SHA1 HMAC_SHA1 | |
50 #define srtp_auth_t auth_t | |
51 #endif | |
52 | |
53 #if defined(HAVE_SRTP) && defined(ENABLE_EXTERNAL_AUTH) | 36 #if defined(HAVE_SRTP) && defined(ENABLE_EXTERNAL_AUTH) |
54 | 37 |
55 #define EXTERNAL_HMAC_SHA1 SRTP_HMAC_SHA1 + 1 | 38 #define EXTERNAL_HMAC_SHA1 SRTP_HMAC_SHA1 + 1 |
56 #define HMAC_KEY_LENGTH 20 | 39 #define HMAC_KEY_LENGTH 20 |
57 | 40 |
58 // The HMAC context structure used to store authentication keys. | 41 // The HMAC context structure used to store authentication keys. |
59 // The pointer to the key will be allocated in the external_hmac_init function. | 42 // The pointer to the key will be allocated in the external_hmac_init function. |
60 // This pointer is owned by srtp_t in a template context. | 43 // This pointer is owned by srtp_t in a template context. |
61 typedef struct { | 44 typedef struct { |
62 uint8_t key[HMAC_KEY_LENGTH]; | 45 uint8_t key[HMAC_KEY_LENGTH]; |
(...skipping 19 matching lines...) Expand all Loading... |
82 srtp_err_status_t external_hmac_compute(ExternalHmacContext* state, | 65 srtp_err_status_t external_hmac_compute(ExternalHmacContext* state, |
83 const void* message, | 66 const void* message, |
84 int msg_octets, | 67 int msg_octets, |
85 int tag_len, | 68 int tag_len, |
86 uint8_t* result); | 69 uint8_t* result); |
87 | 70 |
88 srtp_err_status_t external_crypto_init(); | 71 srtp_err_status_t external_crypto_init(); |
89 | 72 |
90 #endif // defined(HAVE_SRTP) && defined(ENABLE_EXTERNAL_AUTH) | 73 #endif // defined(HAVE_SRTP) && defined(ENABLE_EXTERNAL_AUTH) |
91 #endif // WEBRTC_PC_EXTERNALHMAC_H_ | 74 #endif // WEBRTC_PC_EXTERNALHMAC_H_ |
OLD | NEW |