Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

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

Issue 1528843005: Add support for GCM cipher suites from RFC 7714. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added PeerConnection tests using GCM ciphers, fixed passing of flag through DtlsTransportChannel. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
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 11 matching lines...) Expand all
22 #endif // SSL_USE_OPENSSL 22 #endif // SSL_USE_OPENSSL
23 23
24 /////////////////////////////////////////////////////////////////////////////// 24 ///////////////////////////////////////////////////////////////////////////////
25 25
26 namespace rtc { 26 namespace rtc {
27 27
28 // TODO(guoweis): Move this to SDP layer and use int form internally. 28 // TODO(guoweis): Move this to SDP layer and use int form internally.
29 // webrtc:5043. 29 // webrtc:5043.
30 const char CS_AES_CM_128_HMAC_SHA1_80[] = "AES_CM_128_HMAC_SHA1_80"; 30 const char CS_AES_CM_128_HMAC_SHA1_80[] = "AES_CM_128_HMAC_SHA1_80";
31 const char CS_AES_CM_128_HMAC_SHA1_32[] = "AES_CM_128_HMAC_SHA1_32"; 31 const char CS_AES_CM_128_HMAC_SHA1_32[] = "AES_CM_128_HMAC_SHA1_32";
32 const char CS_AEAD_AES_128_GCM[] = "AEAD_AES_128_GCM";
33 const char CS_AEAD_AES_256_GCM[] = "AEAD_AES_256_GCM";
32 34
33 std::string SrtpCryptoSuiteToName(int crypto_suite) { 35 std::string SrtpCryptoSuiteToName(int crypto_suite) {
34 if (crypto_suite == SRTP_AES128_CM_SHA1_32) 36 switch (crypto_suite) {
37 case SRTP_AES128_CM_SHA1_32:
35 return CS_AES_CM_128_HMAC_SHA1_32; 38 return CS_AES_CM_128_HMAC_SHA1_32;
36 if (crypto_suite == SRTP_AES128_CM_SHA1_80) 39 case SRTP_AES128_CM_SHA1_80:
37 return CS_AES_CM_128_HMAC_SHA1_80; 40 return CS_AES_CM_128_HMAC_SHA1_80;
38 return std::string(); 41 case SRTP_AEAD_AES_128_GCM:
42 return CS_AEAD_AES_128_GCM;
43 case SRTP_AEAD_AES_256_GCM:
44 return CS_AEAD_AES_256_GCM;
45 default:
46 return std::string();
47 }
39 } 48 }
40 49
41 int SrtpCryptoSuiteFromName(const std::string& crypto_suite) { 50 int SrtpCryptoSuiteFromName(const std::string& crypto_suite) {
42 if (crypto_suite == CS_AES_CM_128_HMAC_SHA1_32) 51 if (crypto_suite == CS_AES_CM_128_HMAC_SHA1_32)
43 return SRTP_AES128_CM_SHA1_32; 52 return SRTP_AES128_CM_SHA1_32;
44 if (crypto_suite == CS_AES_CM_128_HMAC_SHA1_80) 53 if (crypto_suite == CS_AES_CM_128_HMAC_SHA1_80)
45 return SRTP_AES128_CM_SHA1_80; 54 return SRTP_AES128_CM_SHA1_80;
55 if (crypto_suite == CS_AEAD_AES_128_GCM)
56 return SRTP_AEAD_AES_128_GCM;
57 if (crypto_suite == CS_AEAD_AES_256_GCM)
58 return SRTP_AEAD_AES_256_GCM;
46 return SRTP_INVALID_CRYPTO_SUITE; 59 return SRTP_INVALID_CRYPTO_SUITE;
47 } 60 }
48 61
62 bool SrtpCryptoSuiteParams(int crypto_suite, int *key_length,
63 int *salt_length) {
64 switch (crypto_suite) {
65 case SRTP_AES128_CM_SHA1_32:
66 case SRTP_AES128_CM_SHA1_80:
67 *key_length = 16;
68 *salt_length = 14;
69 break;
70 case SRTP_AEAD_AES_128_GCM:
71 *key_length = 16;
72 *salt_length = 12;
73 break;
74 case SRTP_AEAD_AES_256_GCM:
75 *key_length = 32;
76 *salt_length = 12;
77 break;
78 default:
79 return false;
80 }
81 return true;
82 }
83
84
49 SSLStreamAdapter* SSLStreamAdapter::Create(StreamInterface* stream) { 85 SSLStreamAdapter* SSLStreamAdapter::Create(StreamInterface* stream) {
50 #if SSL_USE_OPENSSL 86 #if SSL_USE_OPENSSL
51 return new OpenSSLStreamAdapter(stream); 87 return new OpenSSLStreamAdapter(stream);
52 #else // !SSL_USE_OPENSSL 88 #else // !SSL_USE_OPENSSL
53 return NULL; 89 return NULL;
54 #endif // SSL_USE_OPENSSL 90 #endif // SSL_USE_OPENSSL
55 } 91 }
56 92
57 bool SSLStreamAdapter::GetSslCipherSuite(int* cipher_suite) { 93 bool SSLStreamAdapter::GetSslCipherSuite(int* cipher_suite) {
58 return false; 94 return false;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 128 }
93 129
94 std::string SSLStreamAdapter::SslCipherSuiteToName(int cipher_suite) { 130 std::string SSLStreamAdapter::SslCipherSuiteToName(int cipher_suite) {
95 return OpenSSLStreamAdapter::SslCipherSuiteToName(cipher_suite); 131 return OpenSSLStreamAdapter::SslCipherSuiteToName(cipher_suite);
96 } 132 }
97 #endif // SSL_USE_OPENSSL 133 #endif // SSL_USE_OPENSSL
98 134
99 /////////////////////////////////////////////////////////////////////////////// 135 ///////////////////////////////////////////////////////////////////////////////
100 136
101 } // namespace rtc 137 } // namespace rtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698