str0m_openssl/
lib.rs

1//! OpenSSL implementation of cryptographic functions.
2//! DTLS via OpenSSL's native DTLS implementation.
3
4mod dtls;
5mod sha1;
6mod sha256;
7mod srtp;
8
9use dtls::OsslDtlsProvider;
10use sha1::OsslSha1HmacProvider;
11use sha256::OsslSha256Provider;
12use srtp::OsslSrtpProvider;
13use str0m_proto::crypto::CryptoProvider;
14
15#[macro_use]
16extern crate tracing;
17
18/// Create the default OpenSSL crypto provider.
19///
20/// This provider implements all cryptographic operations required for WebRTC:
21/// - DTLS 1.2 for secure key exchange (using dimpl protocol + OpenSSL TLS)
22/// - SRTP for encrypted media
23/// - SHA1-HMAC for STUN message integrity
24/// - SHA-256 for certificate fingerprints
25///
26/// # Supported SRTP Profiles
27///
28/// - `SRTP_AES128_CM_SHA1_80`
29/// - `SRTP_AEAD_AES_128_GCM`
30/// - `SRTP_AEAD_AES_256_GCM`
31pub fn default_provider() -> CryptoProvider {
32    static SRTP: OsslSrtpProvider = OsslSrtpProvider;
33    static SHA1_HMAC: OsslSha1HmacProvider = OsslSha1HmacProvider;
34    static SHA256: OsslSha256Provider = OsslSha256Provider;
35    static DTLS: OsslDtlsProvider = OsslDtlsProvider;
36
37    CryptoProvider {
38        srtp_provider: &SRTP,
39        sha1_hmac_provider: &SHA1_HMAC,
40        sha256_provider: &SHA256,
41        dtls_provider: &DTLS,
42    }
43}