henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #if HAVE_CONFIG_H |
| 12 | #include "config.h" |
| 13 | #endif // HAVE_CONFIG_H |
| 14 | |
| 15 | #include "webrtc/base/sslstreamadapter.h" |
| 16 | #include "webrtc/base/sslconfig.h" |
| 17 | |
torbjorng | 172f009 | 2015-10-07 04:57:55 -0700 | [diff] [blame] | 18 | #if SSL_USE_OPENSSL |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 19 | |
| 20 | #include "webrtc/base/opensslstreamadapter.h" |
| 21 | |
torbjorng | 172f009 | 2015-10-07 04:57:55 -0700 | [diff] [blame] | 22 | #endif // SSL_USE_OPENSSL |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 23 | |
| 24 | /////////////////////////////////////////////////////////////////////////////// |
| 25 | |
| 26 | namespace rtc { |
| 27 | |
Guo-wei Shieh | 456696a | 2015-09-30 21:48:54 -0700 | [diff] [blame] | 28 | // TODO(guoweis): Move this to SDP layer and use int form internally. |
| 29 | // webrtc:5043. |
| 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"; |
| 32 | |
guoweis | 318166b | 2015-11-18 19:03:38 -0800 | [diff] [blame^] | 33 | int GetSrtpCryptoSuiteFromName(const std::string& cipher) { |
| 34 | if (cipher == CS_AES_CM_128_HMAC_SHA1_32) |
Guo-wei Shieh | 456696a | 2015-09-30 21:48:54 -0700 | [diff] [blame] | 35 | return SRTP_AES128_CM_SHA1_32; |
guoweis | 318166b | 2015-11-18 19:03:38 -0800 | [diff] [blame^] | 36 | if (cipher == CS_AES_CM_128_HMAC_SHA1_80) |
Guo-wei Shieh | 456696a | 2015-09-30 21:48:54 -0700 | [diff] [blame] | 37 | return SRTP_AES128_CM_SHA1_80; |
guoweis | 318166b | 2015-11-18 19:03:38 -0800 | [diff] [blame^] | 38 | return 0; |
Guo-wei Shieh | 456696a | 2015-09-30 21:48:54 -0700 | [diff] [blame] | 39 | } |
| 40 | |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 41 | SSLStreamAdapter* SSLStreamAdapter::Create(StreamInterface* stream) { |
torbjorng | 172f009 | 2015-10-07 04:57:55 -0700 | [diff] [blame] | 42 | #if SSL_USE_OPENSSL |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 43 | return new OpenSSLStreamAdapter(stream); |
torbjorng | 172f009 | 2015-10-07 04:57:55 -0700 | [diff] [blame] | 44 | #else // !SSL_USE_OPENSSL |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 45 | return NULL; |
torbjorng | 172f009 | 2015-10-07 04:57:55 -0700 | [diff] [blame] | 46 | #endif // SSL_USE_OPENSSL |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 47 | } |
| 48 | |
guoweis | 318166b | 2015-11-18 19:03:38 -0800 | [diff] [blame^] | 49 | bool SSLStreamAdapter::GetSslCipherSuite(int* cipher) { |
kwiberg@webrtc.org | 67186fe | 2015-03-09 22:21:53 +0000 | [diff] [blame] | 50 | return false; |
| 51 | } |
| 52 | |
| 53 | bool SSLStreamAdapter::ExportKeyingMaterial(const std::string& label, |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 54 | const uint8_t* context, |
kwiberg@webrtc.org | 67186fe | 2015-03-09 22:21:53 +0000 | [diff] [blame] | 55 | size_t context_len, |
| 56 | bool use_context, |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 57 | uint8_t* result, |
kwiberg@webrtc.org | 67186fe | 2015-03-09 22:21:53 +0000 | [diff] [blame] | 58 | size_t result_len) { |
| 59 | return false; // Default is unsupported |
| 60 | } |
| 61 | |
guoweis | 318166b | 2015-11-18 19:03:38 -0800 | [diff] [blame^] | 62 | bool SSLStreamAdapter::SetDtlsSrtpCiphers( |
| 63 | const std::vector<std::string>& ciphers) { |
kwiberg@webrtc.org | 67186fe | 2015-03-09 22:21:53 +0000 | [diff] [blame] | 64 | return false; |
| 65 | } |
| 66 | |
guoweis | 318166b | 2015-11-18 19:03:38 -0800 | [diff] [blame^] | 67 | bool SSLStreamAdapter::GetDtlsSrtpCipher(std::string* cipher) { |
kwiberg@webrtc.org | 67186fe | 2015-03-09 22:21:53 +0000 | [diff] [blame] | 68 | return false; |
| 69 | } |
| 70 | |
torbjorng | 172f009 | 2015-10-07 04:57:55 -0700 | [diff] [blame] | 71 | #if SSL_USE_OPENSSL |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 72 | bool SSLStreamAdapter::HaveDtls() { |
| 73 | return OpenSSLStreamAdapter::HaveDtls(); |
| 74 | } |
| 75 | bool SSLStreamAdapter::HaveDtlsSrtp() { |
| 76 | return OpenSSLStreamAdapter::HaveDtlsSrtp(); |
| 77 | } |
| 78 | bool SSLStreamAdapter::HaveExporter() { |
| 79 | return OpenSSLStreamAdapter::HaveExporter(); |
| 80 | } |
Guo-wei Shieh | 6caafbe | 2015-10-05 12:43:27 -0700 | [diff] [blame] | 81 | int SSLStreamAdapter::GetDefaultSslCipherForTest(SSLProtocolVersion version, |
| 82 | KeyType key_type) { |
Guo-wei Shieh | 456696a | 2015-09-30 21:48:54 -0700 | [diff] [blame] | 83 | return OpenSSLStreamAdapter::GetDefaultSslCipherForTest(version, key_type); |
| 84 | } |
| 85 | |
guoweis | 318166b | 2015-11-18 19:03:38 -0800 | [diff] [blame^] | 86 | std::string SSLStreamAdapter::GetSslCipherSuiteName(int cipher) { |
| 87 | return OpenSSLStreamAdapter::GetSslCipherSuiteName(cipher); |
pthatcher@webrtc.org | 3ee4fe5 | 2015-02-11 22:34:36 +0000 | [diff] [blame] | 88 | } |
torbjorng | 172f009 | 2015-10-07 04:57:55 -0700 | [diff] [blame] | 89 | #endif // SSL_USE_OPENSSL |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 90 | |
| 91 | /////////////////////////////////////////////////////////////////////////////// |
| 92 | |
| 93 | } // namespace rtc |