File
Blob: firmware/crates/esp32-radio/src/platform/crypto/dtls.rs
| 1 | use super::{ec, hashes::Hashes, signature::Verifier, suites}; |
| 2 | use radio_webrtc::crypto::{ |
| 3 | CryptoError, |
| 4 | dtls::{DtlsCert, DtlsInstance, DtlsProvider, DtlsVersion}, |
| 5 | }; |
| 6 | use std::time::Instant; |
| 7 | |
| 8 | #[derive(Debug)] |
| 9 | pub(super) struct Provider; |
| 10 | impl DtlsProvider for Provider { |
| 11 | fn generate_certificate(&self) -> Option<DtlsCert> { |
| 12 | None |
| 13 | } |
| 14 | fn new_dtls( |
| 15 | &self, |
| 16 | cert: &DtlsCert, |
| 17 | now: Instant, |
| 18 | version: DtlsVersion, |
| 19 | mtu: Option<usize>, |
| 20 | ) -> Result<Box<dyn DtlsInstance>, CryptoError> { |
| 21 | let mut crypto = dimpl::crypto::rust_crypto::default_provider(); |
| 22 | crypto.kx_groups = ec::GROUPS; |
| 23 | crypto.key_provider = &ec::Keys; |
| 24 | crypto.hash_provider = &Hashes; |
| 25 | crypto.hmac_provider = &Hashes; |
| 26 | crypto.signature_verification = &Verifier; |
| 27 | suites::install(&mut crypto); |
| 28 | str0m_rust_crypto::dtls_with_crypto_provider(cert, now, version, mtu, crypto) |
| 29 | } |
| 30 | } |