pub struct TlsProvider {
pub server: Option<Arc<ServerConfig>>,
pub client: Option<Arc<ClientConfig>>,
/* private fields */
}Expand description
TLS-backed crypto for an endpoint. A server needs server, a client client; the
configurations must list ALPN protocols (h3 for HTTP/3). Build a client provider with
TlsProvider::client or TlsProvider::with_client (which link the TLS client); a
provider made with TlsProvider::server refuses client sessions.
Fields§
§server: Option<Arc<ServerConfig>>§client: Option<Arc<ClientConfig>>Implementations§
Source§impl TlsProvider
impl TlsProvider
Sourcepub fn server(cfg: Arc<ServerConfig>) -> Self
pub fn server(cfg: Arc<ServerConfig>) -> Self
Examples found in repository?
examples/bench_quic.rs (line 25)
19fn providers(real: bool) -> (Arc<dyn CryptoProvider>, Arc<dyn CryptoProvider>) {
20 if !real {
21 return (Arc::new(NullProvider::new(1)), Arc::new(NullProvider::new(2)));
22 }
23 let ss = certgen::issue(&CertParams::server(&["localhost"]), PrivateKey::generate_ec(EcCurve::P256), None);
24 let ck = simoom_tls::CertifiedKey::new(vec![ss.cert_der.clone()], ss.key.clone()).unwrap();
25 let s = TlsProvider::server(Arc::new(simoom_tls::ServerConfig::new(ck).with_alpn(&[b"h3"])));
26 let mut roots = simoom_tls::x509::RootStore::empty();
27 roots.add_der(&ss.cert_der).unwrap();
28 let c = TlsProvider::client(Arc::new(simoom_tls::ClientConfig::new(roots).with_alpn(&[b"h3"])));
29 (Arc::new(c), Arc::new(s))
30}Sourcepub fn client(cfg: Arc<ClientConfig>) -> Self
pub fn client(cfg: Arc<ClientConfig>) -> Self
Examples found in repository?
examples/bench_quic.rs (line 28)
19fn providers(real: bool) -> (Arc<dyn CryptoProvider>, Arc<dyn CryptoProvider>) {
20 if !real {
21 return (Arc::new(NullProvider::new(1)), Arc::new(NullProvider::new(2)));
22 }
23 let ss = certgen::issue(&CertParams::server(&["localhost"]), PrivateKey::generate_ec(EcCurve::P256), None);
24 let ck = simoom_tls::CertifiedKey::new(vec![ss.cert_der.clone()], ss.key.clone()).unwrap();
25 let s = TlsProvider::server(Arc::new(simoom_tls::ServerConfig::new(ck).with_alpn(&[b"h3"])));
26 let mut roots = simoom_tls::x509::RootStore::empty();
27 roots.add_der(&ss.cert_der).unwrap();
28 let c = TlsProvider::client(Arc::new(simoom_tls::ClientConfig::new(roots).with_alpn(&[b"h3"])));
29 (Arc::new(c), Arc::new(s))
30}Sourcepub fn with_client(self, cfg: Arc<ClientConfig>) -> Self
pub fn with_client(self, cfg: Arc<ClientConfig>) -> Self
Adds a client configuration (an endpoint that both accepts and opens connections).
Trait Implementations§
Source§impl CryptoProvider for TlsProvider
impl CryptoProvider for TlsProvider
Source§fn initial_keys(&self, version: u32, dcid: &[u8], is_server: bool) -> Keys
fn initial_keys(&self, version: u32, dcid: &[u8], is_server: bool) -> Keys
Initial keys derived from the client’s first destination connection ID.
Source§fn retry_tag(&self, version: u32, pseudo: &[u8]) -> [u8; 16]
fn retry_tag(&self, version: u32, pseudo: &[u8]) -> [u8; 16]
The Retry integrity tag over the Retry pseudo-packet (RFC 9001 §5.8).
Source§fn hmac(&self, key: &[u8; 32], parts: &[&[u8]]) -> [u8; 32]
fn hmac(&self, key: &[u8; 32], parts: &[&[u8]]) -> [u8; 32]
HMAC-SHA256 over the concatenation of
parts.Source§fn fill_random(&self, buf: &mut [u8])
fn fill_random(&self, buf: &mut [u8])
Cryptographically secure random bytes.
Source§fn server_session(
&self,
version: u32,
tp: Vec<u8>,
) -> Result<Box<dyn CryptoSession>, TransportError>
fn server_session( &self, version: u32, tp: Vec<u8>, ) -> Result<Box<dyn CryptoSession>, TransportError>
Starts a server handshake for QUIC
version that will send transport_params.Source§fn client_session(
&self,
version: u32,
name: &str,
tp: Vec<u8>,
) -> Result<Box<dyn CryptoSession>, TransportError>
fn client_session( &self, version: u32, name: &str, tp: Vec<u8>, ) -> Result<Box<dyn CryptoSession>, TransportError>
Starts a client handshake to
server_name that will send transport_params.Auto Trait Implementations§
impl !RefUnwindSafe for TlsProvider
impl !UnwindSafe for TlsProvider
impl Forget for TlsProvider
impl Freeze for TlsProvider
impl Move for TlsProvider
impl Send for TlsProvider
impl Sync for TlsProvider
impl Unpin for TlsProvider
impl UnsafeUnpin for TlsProvider
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more