/* * Copyright 2004 The WebRTC Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef RTC_BASE_SSL_STREAM_ADAPTER_H_ #define RTC_BASE_SSL_STREAM_ADAPTER_H_ #include <stddef.h> #include <stdint.h> #include <memory> #include <string> #include <vector> #include "absl/functional/any_invocable.h" #include "absl/memory/memory.h" #include "absl/strings/string_view.h" #include "rtc_base/ssl_certificate.h" #include "rtc_base/ssl_identity.h" #include "rtc_base/stream.h" namespace rtc { // Constants for SSL profile. constexpr int kTlsNullWithNullNull = …; constexpr int kSslCipherSuiteMaxValue = …; // Constants for SRTP profiles. constexpr int kSrtpInvalidCryptoSuite = …; constexpr int kSrtpAes128CmSha1_80 = …; constexpr int kSrtpAes128CmSha1_32 = …; constexpr int kSrtpAeadAes128Gcm = …; constexpr int kSrtpAeadAes256Gcm = …; constexpr int kSrtpCryptoSuiteMaxValue = …; // Constants for SSL signature algorithms. constexpr int kSslSignatureAlgorithmUnknown = …; constexpr int kSslSignatureAlgorithmMaxValue = …; // Names of SRTP profiles listed above. // 128-bit AES with 80-bit SHA-1 HMAC. extern const char kCsAesCm128HmacSha1_80[]; // 128-bit AES with 32-bit SHA-1 HMAC. extern const char kCsAesCm128HmacSha1_32[]; // 128-bit AES GCM with 16 byte AEAD auth tag. extern const char kCsAeadAes128Gcm[]; // 256-bit AES GCM with 16 byte AEAD auth tag. extern const char kCsAeadAes256Gcm[]; // Given the DTLS-SRTP protection profile ID, as defined in // https://tools.ietf.org/html/rfc4568#section-6.2 , return the SRTP profile // name, as defined in https://tools.ietf.org/html/rfc5764#section-4.1.2. std::string SrtpCryptoSuiteToName(int crypto_suite); // Get key length and salt length for given crypto suite. Returns true for // valid suites, otherwise false. bool GetSrtpKeyAndSaltLengths(int crypto_suite, int* key_length, int* salt_length); // Returns true if the given crypto suite id uses a GCM cipher. bool IsGcmCryptoSuite(int crypto_suite); // SSLStreamAdapter : A StreamInterfaceAdapter that does SSL/TLS. // After SSL has been started, the stream will only open on successful // SSL verification of certificates, and the communication is // encrypted of course. // // This class was written with SSLAdapter as a starting point. It // offers a similar interface, with two differences: there is no // support for a restartable SSL connection, and this class has a // peer-to-peer mode. // // The SSL library requires initialization and cleanup. Static method // for doing this are in SSLAdapter. They should possibly be moved out // to a neutral class. enum SSLRole { … }; enum SSLMode { … }; // TODO bugs.webrtc.org/40644300 remove unused legacy constants. enum SSLProtocolVersion { … }; enum class SSLPeerCertificateDigestError { … }; // Errors for Read -- in the high range so no conflict with OpenSSL. enum { … }; // Used to send back UMA histogram value. Logged when Dtls handshake fails. enum class SSLHandshakeError { … }; class SSLStreamAdapter : public StreamInterface { … }; } // namespace rtc #endif // RTC_BASE_SSL_STREAM_ADAPTER_H_