File
Blob: firmware/vendor/str0m-rust-crypto/src/lib.rs
| 1 | //! RustCrypto implementation of cryptographic functions. |
| 2 | //! DTLS via dimpl with RustCrypto as crypto backend. |
| 3 | |
| 4 | mod dtls; |
| 5 | |
| 6 | pub use dtls::with_crypto_provider as dtls_with_crypto_provider; |
| 7 | mod sha1; |
| 8 | mod sha256; |
| 9 | mod srtp; |
| 10 | |
| 11 | use dtls::RustCryptoDtlsProvider; |
| 12 | use sha1::RustCryptoSha1HmacProvider; |
| 13 | use sha256::RustCryptoSha256Provider; |
| 14 | use srtp::RustCryptoSrtpProvider; |
| 15 | use str0m_proto::crypto::CryptoProvider; |
| 16 | |
| 17 | /// Create the default RustCrypto crypto provider. |
| 18 | /// |
| 19 | /// This provider implements all cryptographic operations required for WebRTC: |
| 20 | /// - DTLS 1.2 for secure key exchange (using dimpl protocol + RustCrypto) |
| 21 | /// - SRTP for encrypted media |
| 22 | /// - SHA1-HMAC for STUN message integrity |
| 23 | /// - SHA-256 for certificate fingerprints |
| 24 | /// |
| 25 | /// # Supported SRTP Profiles |
| 26 | /// |
| 27 | /// - `SRTP_AES128_CM_SHA1_80` |
| 28 | /// - `SRTP_AEAD_AES_128_GCM` |
| 29 | /// - `SRTP_AEAD_AES_256_GCM` |
| 30 | pub fn default_provider() -> CryptoProvider { |
| 31 | static SRTP: RustCryptoSrtpProvider = RustCryptoSrtpProvider; |
| 32 | static SHA1_HMAC: RustCryptoSha1HmacProvider = RustCryptoSha1HmacProvider; |
| 33 | static SHA256: RustCryptoSha256Provider = RustCryptoSha256Provider; |
| 34 | static DTLS: RustCryptoDtlsProvider = RustCryptoDtlsProvider; |
| 35 | |
| 36 | CryptoProvider { |
| 37 | srtp_provider: &SRTP, |
| 38 | sha1_hmac_provider: &SHA1_HMAC, |
| 39 | sha256_provider: &SHA256, |
| 40 | dtls_provider: &DTLS, |
| 41 | } |
| 42 | } |