Skip to main content

TlsProvider

Struct TlsProvider 

Source
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

Source

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}
Source

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}
Source

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

Source§

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]

The Retry integrity tag over the Retry pseudo-packet (RFC 9001 §5.8).
Source§

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])

Cryptographically secure random bytes.
Source§

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>

Starts a client handshake to server_name that will send transport_params.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.