OLD | NEW |
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 |
11 #if HAVE_CONFIG_H | 11 #if HAVE_CONFIG_H |
12 #include "config.h" | 12 #include "config.h" |
13 #endif // HAVE_CONFIG_H | 13 #endif // HAVE_CONFIG_H |
14 | 14 |
15 #include "webrtc/base/sslstreamadapter.h" | 15 #include "webrtc/base/sslstreamadapter.h" |
16 #include "webrtc/base/sslconfig.h" | 16 #include "webrtc/base/sslconfig.h" |
17 | 17 |
18 #if SSL_USE_SCHANNEL | 18 #if SSL_USE_OPENSSL |
19 | |
20 // SChannel support for DTLS and peer-to-peer mode are not | |
21 // done. | |
22 #elif SSL_USE_OPENSSL // && !SSL_USE_SCHANNEL | |
23 | 19 |
24 #include "webrtc/base/opensslstreamadapter.h" | 20 #include "webrtc/base/opensslstreamadapter.h" |
25 | 21 |
26 #endif // !SSL_USE_OPENSSL && !SSL_USE_SCHANNEL | 22 #endif // SSL_USE_OPENSSL |
27 | 23 |
28 /////////////////////////////////////////////////////////////////////////////// | 24 /////////////////////////////////////////////////////////////////////////////// |
29 | 25 |
30 namespace rtc { | 26 namespace rtc { |
31 | 27 |
32 // 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. |
33 // webrtc:5043. | 29 // webrtc:5043. |
34 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"; |
35 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"; |
36 | 32 |
37 int GetSrtpCryptoSuiteFromName(const std::string& cipher) { | 33 int GetSrtpCryptoSuiteFromName(const std::string& cipher) { |
38 if (cipher == CS_AES_CM_128_HMAC_SHA1_32) | 34 if (cipher == CS_AES_CM_128_HMAC_SHA1_32) |
39 return SRTP_AES128_CM_SHA1_32; | 35 return SRTP_AES128_CM_SHA1_32; |
40 if (cipher == CS_AES_CM_128_HMAC_SHA1_80) | 36 if (cipher == CS_AES_CM_128_HMAC_SHA1_80) |
41 return SRTP_AES128_CM_SHA1_80; | 37 return SRTP_AES128_CM_SHA1_80; |
42 return 0; | 38 return 0; |
43 } | 39 } |
44 | 40 |
45 SSLStreamAdapter* SSLStreamAdapter::Create(StreamInterface* stream) { | 41 SSLStreamAdapter* SSLStreamAdapter::Create(StreamInterface* stream) { |
46 #if SSL_USE_SCHANNEL | 42 #if SSL_USE_OPENSSL |
| 43 return new OpenSSLStreamAdapter(stream); |
| 44 #else // !SSL_USE_OPENSSL |
47 return NULL; | 45 return NULL; |
48 #elif SSL_USE_OPENSSL // !SSL_USE_SCHANNEL | 46 #endif // SSL_USE_OPENSSL |
49 return new OpenSSLStreamAdapter(stream); | |
50 #else // !SSL_USE_SCHANNEL && !SSL_USE_OPENSSL | |
51 return NULL; | |
52 #endif | |
53 } | 47 } |
54 | 48 |
55 bool SSLStreamAdapter::GetSslCipherSuite(int* cipher) { | 49 bool SSLStreamAdapter::GetSslCipherSuite(int* cipher) { |
56 return false; | 50 return false; |
57 } | 51 } |
58 | 52 |
59 bool SSLStreamAdapter::ExportKeyingMaterial(const std::string& label, | 53 bool SSLStreamAdapter::ExportKeyingMaterial(const std::string& label, |
60 const uint8* context, | 54 const uint8* context, |
61 size_t context_len, | 55 size_t context_len, |
62 bool use_context, | 56 bool use_context, |
63 uint8* result, | 57 uint8* result, |
64 size_t result_len) { | 58 size_t result_len) { |
65 return false; // Default is unsupported | 59 return false; // Default is unsupported |
66 } | 60 } |
67 | 61 |
68 bool SSLStreamAdapter::SetDtlsSrtpCiphers( | 62 bool SSLStreamAdapter::SetDtlsSrtpCiphers( |
69 const std::vector<std::string>& ciphers) { | 63 const std::vector<std::string>& ciphers) { |
70 return false; | 64 return false; |
71 } | 65 } |
72 | 66 |
73 bool SSLStreamAdapter::GetDtlsSrtpCipher(std::string* cipher) { | 67 bool SSLStreamAdapter::GetDtlsSrtpCipher(std::string* cipher) { |
74 return false; | 68 return false; |
75 } | 69 } |
76 | 70 |
77 // Note: this matches the logic above with SCHANNEL dominating | 71 #if SSL_USE_OPENSSL |
78 #if SSL_USE_SCHANNEL | |
79 bool SSLStreamAdapter::HaveDtls() { return false; } | |
80 bool SSLStreamAdapter::HaveDtlsSrtp() { return false; } | |
81 bool SSLStreamAdapter::HaveExporter() { return false; } | |
82 int SSLStreamAdapter::GetDefaultSslCipherForTest(SSLProtocolVersion version, | |
83 KeyType key_type) { | |
84 return 0; | |
85 } | |
86 #elif SSL_USE_OPENSSL | |
87 bool SSLStreamAdapter::HaveDtls() { | 72 bool SSLStreamAdapter::HaveDtls() { |
88 return OpenSSLStreamAdapter::HaveDtls(); | 73 return OpenSSLStreamAdapter::HaveDtls(); |
89 } | 74 } |
90 bool SSLStreamAdapter::HaveDtlsSrtp() { | 75 bool SSLStreamAdapter::HaveDtlsSrtp() { |
91 return OpenSSLStreamAdapter::HaveDtlsSrtp(); | 76 return OpenSSLStreamAdapter::HaveDtlsSrtp(); |
92 } | 77 } |
93 bool SSLStreamAdapter::HaveExporter() { | 78 bool SSLStreamAdapter::HaveExporter() { |
94 return OpenSSLStreamAdapter::HaveExporter(); | 79 return OpenSSLStreamAdapter::HaveExporter(); |
95 } | 80 } |
96 int SSLStreamAdapter::GetDefaultSslCipherForTest(SSLProtocolVersion version, | 81 int SSLStreamAdapter::GetDefaultSslCipherForTest(SSLProtocolVersion version, |
97 KeyType key_type) { | 82 KeyType key_type) { |
98 return OpenSSLStreamAdapter::GetDefaultSslCipherForTest(version, key_type); | 83 return OpenSSLStreamAdapter::GetDefaultSslCipherForTest(version, key_type); |
99 } | 84 } |
100 | 85 |
101 std::string SSLStreamAdapter::GetSslCipherSuiteName(int cipher) { | 86 std::string SSLStreamAdapter::GetSslCipherSuiteName(int cipher) { |
102 return OpenSSLStreamAdapter::GetSslCipherSuiteName(cipher); | 87 return OpenSSLStreamAdapter::GetSslCipherSuiteName(cipher); |
103 } | 88 } |
104 #endif // !SSL_USE_SCHANNEL && !SSL_USE_OPENSSL | 89 #endif // SSL_USE_OPENSSL |
105 | 90 |
106 /////////////////////////////////////////////////////////////////////////////// | 91 /////////////////////////////////////////////////////////////////////////////// |
107 | 92 |
108 } // namespace rtc | 93 } // namespace rtc |
OLD | NEW |