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 |
11 #ifndef WEBRTC_PC_EXTERNALHMAC_H_ | 11 #ifndef WEBRTC_PC_EXTERNALHMAC_H_ |
12 #define WEBRTC_PC_EXTERNALHMAC_H_ | 12 #define WEBRTC_PC_EXTERNALHMAC_H_ |
13 | 13 |
14 // External libsrtp HMAC auth module which implements methods defined in | 14 // External libsrtp HMAC auth module which implements methods defined in |
15 // auth_type_t. | 15 // auth_type_t. |
16 // The default auth module will be replaced only when the ENABLE_EXTERNAL_AUTH | 16 // The default auth module will be replaced only when the ENABLE_EXTERNAL_AUTH |
17 // flag is enabled. This allows us to access to authentication keys, | 17 // flag is enabled. This allows us to access to authentication keys, |
18 // as the default auth implementation doesn't provide access and avoids | 18 // as the default auth implementation doesn't provide access and avoids |
19 // hashing each packet twice. | 19 // hashing each packet twice. |
20 | 20 |
21 // How will libsrtp select this module? | 21 // How will libsrtp select this module? |
22 // Libsrtp defines authentication function types identified by an unsigned | 22 // Libsrtp defines authentication function types identified by an unsigned |
23 // integer, e.g. HMAC_SHA1 is 3. Using authentication ids, the application | 23 // integer, e.g. HMAC_SHA1 is 3. Using authentication ids, the application |
24 // can plug any desired authentication modules into libsrtp. | 24 // 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 #if defined(HAVE_SRTP) && defined(ENABLE_EXTERNAL_AUTH) | |
31 | 30 |
32 #include "webrtc/base/basictypes.h" | 31 #include "webrtc/base/basictypes.h" |
| 32 #ifdef HAVE_SRTP |
33 extern "C" { | 33 extern "C" { |
34 #ifdef SRTP_RELATIVE_PATH | 34 #ifdef SRTP_RELATIVE_PATH |
35 #include "auth.h" // NOLINT | 35 #include "auth.h" // NOLINT |
36 #else | 36 #else |
37 #include "third_party/libsrtp/srtp/crypto/include/auth.h" | 37 #include "third_party/libsrtp/crypto/include/auth.h" |
38 #endif // SRTP_RELATIVE_PATH | 38 #endif // SRTP_RELATIVE_PATH |
39 } | 39 } |
| 40 #endif // HAVE_SRTP |
| 41 |
| 42 #if defined(HAVE_SRTP) && defined(ENABLE_EXTERNAL_AUTH) |
40 | 43 |
41 #define EXTERNAL_HMAC_SHA1 HMAC_SHA1 + 1 | 44 #define EXTERNAL_HMAC_SHA1 HMAC_SHA1 + 1 |
42 #define HMAC_KEY_LENGTH 20 | 45 #define HMAC_KEY_LENGTH 20 |
43 | 46 |
44 // The HMAC context structure used to store authentication keys. | 47 // The HMAC context structure used to store authentication keys. |
45 // The pointer to the key will be allocated in the external_hmac_init function. | 48 // The pointer to the key will be allocated in the external_hmac_init function. |
46 // This pointer is owned by srtp_t in a template context. | 49 // This pointer is owned by srtp_t in a template context. |
47 typedef struct { | 50 typedef struct { |
48 uint8_t key[HMAC_KEY_LENGTH]; | 51 uint8_t key[HMAC_KEY_LENGTH]; |
49 int key_length; | 52 int key_length; |
(...skipping 16 matching lines...) Expand all Loading... |
66 err_status_t external_hmac_compute(ExternalHmacContext* state, | 69 err_status_t external_hmac_compute(ExternalHmacContext* state, |
67 const void* message, | 70 const void* message, |
68 int msg_octets, | 71 int msg_octets, |
69 int tag_len, | 72 int tag_len, |
70 uint8_t* result); | 73 uint8_t* result); |
71 | 74 |
72 err_status_t external_crypto_init(); | 75 err_status_t external_crypto_init(); |
73 | 76 |
74 #endif // defined(HAVE_SRTP) && defined(ENABLE_EXTERNAL_AUTH) | 77 #endif // defined(HAVE_SRTP) && defined(ENABLE_EXTERNAL_AUTH) |
75 #endif // WEBRTC_PC_EXTERNALHMAC_H_ | 78 #endif // WEBRTC_PC_EXTERNALHMAC_H_ |
OLD | NEW |