Chromium Code Reviews

Side by Side Diff: webrtc/base/sslstreamadapter.h

Issue 1528843005: Add support for GCM cipher suites from RFC 7714. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix failing SRTP-but-no-DTLS tests. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 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 13 matching lines...)
24 const int TLS_NULL_WITH_NULL_NULL = 0; 24 const int TLS_NULL_WITH_NULL_NULL = 0;
25 25
26 // Constants for SRTP profiles. 26 // Constants for SRTP profiles.
27 const int SRTP_INVALID_CRYPTO_SUITE = 0; 27 const int SRTP_INVALID_CRYPTO_SUITE = 0;
28 #ifndef SRTP_AES128_CM_SHA1_80 28 #ifndef SRTP_AES128_CM_SHA1_80
29 const int SRTP_AES128_CM_SHA1_80 = 0x0001; 29 const int SRTP_AES128_CM_SHA1_80 = 0x0001;
30 #endif 30 #endif
31 #ifndef SRTP_AES128_CM_SHA1_32 31 #ifndef SRTP_AES128_CM_SHA1_32
32 const int SRTP_AES128_CM_SHA1_32 = 0x0002; 32 const int SRTP_AES128_CM_SHA1_32 = 0x0002;
33 #endif 33 #endif
34 #ifndef SRTP_AEAD_AES_128_GCM
35 const int SRTP_AEAD_AES_128_GCM = 0x0007;
36 #endif
37 #ifndef SRTP_AEAD_AES_256_GCM
38 const int SRTP_AEAD_AES_256_GCM = 0x0008;
39 #endif
34 40
35 // Cipher suite to use for SRTP. Typically a 80-bit HMAC will be used, except 41 // Cipher suite to use for SRTP. Typically a 80-bit HMAC will be used, except
36 // in applications (voice) where the additional bandwidth may be significant. 42 // in applications (voice) where the additional bandwidth may be significant.
37 // A 80-bit HMAC is always used for SRTCP. 43 // A 80-bit HMAC is always used for SRTCP.
38 // 128-bit AES with 80-bit SHA-1 HMAC. 44 // 128-bit AES with 80-bit SHA-1 HMAC.
39 extern const char CS_AES_CM_128_HMAC_SHA1_80[]; 45 extern const char CS_AES_CM_128_HMAC_SHA1_80[];
40 // 128-bit AES with 32-bit SHA-1 HMAC. 46 // 128-bit AES with 32-bit SHA-1 HMAC.
41 extern const char CS_AES_CM_128_HMAC_SHA1_32[]; 47 extern const char CS_AES_CM_128_HMAC_SHA1_32[];
48 // 128-bit AES GCM with 16 byte AEAD auth tag.
49 extern const char CS_AEAD_AES_128_GCM[];
50 // 256-bit AES GCM with 16 byte AEAD auth tag.
51 extern const char CS_AEAD_AES_256_GCM[];
42 52
43 // Given the DTLS-SRTP protection profile ID, as defined in 53 // Given the DTLS-SRTP protection profile ID, as defined in
44 // https://tools.ietf.org/html/rfc4568#section-6.2 , return the SRTP profile 54 // https://tools.ietf.org/html/rfc4568#section-6.2 , return the SRTP profile
45 // name, as defined in https://tools.ietf.org/html/rfc5764#section-4.1.2. 55 // name, as defined in https://tools.ietf.org/html/rfc5764#section-4.1.2.
46 std::string SrtpCryptoSuiteToName(int crypto_suite); 56 std::string SrtpCryptoSuiteToName(int crypto_suite);
47 57
48 // The reverse of above conversion. 58 // The reverse of above conversion.
49 int SrtpCryptoSuiteFromName(const std::string& crypto_suite); 59 int SrtpCryptoSuiteFromName(const std::string& crypto_suite);
50 60
61 // Get key length and salt length for given crypto suite. Returns true for
62 // valid suites, otherwise false.
63 bool GetSrtpKeyAndSaltLengths(int crypto_suite, int *key_length,
64 int *salt_length);
65
66 // Returns true if the given crypto suite id uses a GCM cipher.
67 bool IsGcmCryptoSuite(int crypto_suite);
68
69 // Returns true if the given crypto suite name uses a GCM cipher.
70 bool IsGcmCryptoSuiteName(const std::string& crypto_suite);
71
72 struct CryptoOptions {
73 CryptoOptions() :
mattdr 2016/05/06 22:34:13 The initializer will fit on one line.
joachim 2016/05/09 23:21:40 Done.
74 enable_gcm_crypto_suites(false) {
75 }
76
77 // Enable GCM crypto suites from RFC 7714 for SRTP. GCM will only be used
78 // if both sides enable it.
79 bool enable_gcm_crypto_suites;
80 };
81
51 // SSLStreamAdapter : A StreamInterfaceAdapter that does SSL/TLS. 82 // SSLStreamAdapter : A StreamInterfaceAdapter that does SSL/TLS.
52 // After SSL has been started, the stream will only open on successful 83 // After SSL has been started, the stream will only open on successful
53 // SSL verification of certificates, and the communication is 84 // SSL verification of certificates, and the communication is
54 // encrypted of course. 85 // encrypted of course.
55 // 86 //
56 // This class was written with SSLAdapter as a starting point. It 87 // This class was written with SSLAdapter as a starting point. It
57 // offers a similar interface, with two differences: there is no 88 // offers a similar interface, with two differences: there is no
58 // support for a restartable SSL connection, and this class has a 89 // support for a restartable SSL connection, and this class has a
59 // peer-to-peer mode. 90 // peer-to-peer mode.
60 // 91 //
(...skipping 153 matching lines...)
214 245
215 // If true (default), the client is required to provide a certificate during 246 // If true (default), the client is required to provide a certificate during
216 // handshake. If no certificate is given, handshake fails. This applies to 247 // handshake. If no certificate is given, handshake fails. This applies to
217 // server mode only. 248 // server mode only.
218 bool client_auth_enabled_; 249 bool client_auth_enabled_;
219 }; 250 };
220 251
221 } // namespace rtc 252 } // namespace rtc
222 253
223 #endif // WEBRTC_BASE_SSLSTREAMADAPTER_H_ 254 #endif // WEBRTC_BASE_SSLSTREAMADAPTER_H_
OLDNEW

Powered by Google App Engine