Skip to main content

str0m_openssl/
lib.rs

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