Benjamin Wright | ac2f3d1 | 2018-10-10 17:21:08 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 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 | #include "api/crypto/cryptooptions.h" |
| 12 | #include "rtc_base/sslstreamadapter.h" |
| 13 | |
| 14 | namespace webrtc { |
| 15 | |
| 16 | CryptoOptions::CryptoOptions() {} |
| 17 | |
| 18 | CryptoOptions::CryptoOptions(const CryptoOptions& other) { |
| 19 | enable_gcm_crypto_suites = other.enable_gcm_crypto_suites; |
| 20 | enable_encrypted_rtp_header_extensions = |
| 21 | other.enable_encrypted_rtp_header_extensions; |
| 22 | srtp = other.srtp; |
| 23 | } |
| 24 | |
| 25 | CryptoOptions::~CryptoOptions() {} |
| 26 | |
| 27 | // static |
| 28 | CryptoOptions CryptoOptions::NoGcm() { |
| 29 | CryptoOptions options; |
| 30 | options.srtp.enable_gcm_crypto_suites = false; |
| 31 | return options; |
| 32 | } |
| 33 | |
| 34 | std::vector<int> CryptoOptions::GetSupportedDtlsSrtpCryptoSuites() const { |
| 35 | std::vector<int> crypto_suites; |
| 36 | if (srtp.enable_gcm_crypto_suites) { |
| 37 | crypto_suites.push_back(rtc::SRTP_AEAD_AES_256_GCM); |
| 38 | crypto_suites.push_back(rtc::SRTP_AEAD_AES_128_GCM); |
| 39 | } |
| 40 | // Note: SRTP_AES128_CM_SHA1_80 is what is required to be supported (by |
| 41 | // draft-ietf-rtcweb-security-arch), but SRTP_AES128_CM_SHA1_32 is allowed as |
| 42 | // well, and saves a few bytes per packet if it ends up selected. |
| 43 | // As the cipher suite is potentially insecure, it will only be used if |
| 44 | // enabled by both peers. |
| 45 | if (srtp.enable_aes128_sha1_32_crypto_cipher) { |
| 46 | crypto_suites.push_back(rtc::SRTP_AES128_CM_SHA1_32); |
| 47 | } |
| 48 | crypto_suites.push_back(rtc::SRTP_AES128_CM_SHA1_80); |
| 49 | return crypto_suites; |
| 50 | } |
| 51 | |
| 52 | } // namespace webrtc |