blob: 2c34822b2801be5d6bd0337347ccf14c9e86498d [file] [log] [blame]
Benjamin Wrighta54daf12018-10-11 15:33:17 -07001/*
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
14namespace webrtc {
15
16CryptoOptions::CryptoOptions() {}
17
18CryptoOptions::CryptoOptions(const CryptoOptions& other) {
Benjamin Wrighta54daf12018-10-11 15:33:17 -070019 srtp = other.srtp;
20}
21
22CryptoOptions::~CryptoOptions() {}
23
24// static
25CryptoOptions CryptoOptions::NoGcm() {
26 CryptoOptions options;
27 options.srtp.enable_gcm_crypto_suites = false;
28 return options;
29}
30
31std::vector<int> CryptoOptions::GetSupportedDtlsSrtpCryptoSuites() const {
32 std::vector<int> crypto_suites;
33 if (srtp.enable_gcm_crypto_suites) {
34 crypto_suites.push_back(rtc::SRTP_AEAD_AES_256_GCM);
35 crypto_suites.push_back(rtc::SRTP_AEAD_AES_128_GCM);
36 }
37 // Note: SRTP_AES128_CM_SHA1_80 is what is required to be supported (by
38 // draft-ietf-rtcweb-security-arch), but SRTP_AES128_CM_SHA1_32 is allowed as
39 // well, and saves a few bytes per packet if it ends up selected.
40 // As the cipher suite is potentially insecure, it will only be used if
41 // enabled by both peers.
42 if (srtp.enable_aes128_sha1_32_crypto_cipher) {
43 crypto_suites.push_back(rtc::SRTP_AES128_CM_SHA1_32);
44 }
45 crypto_suites.push_back(rtc::SRTP_AES128_CM_SHA1_80);
46 return crypto_suites;
47}
48
49} // namespace webrtc