mirror of
https://github.com/n0-computer/noq.git
synced 2026-09-25 21:02:46 +00:00
Erase crypto::Session::Identity
This commit is contained in:
@@ -29,8 +29,6 @@ pub(crate) mod types;
|
||||
|
||||
/// A cryptographic session (commonly TLS)
|
||||
pub trait Session: Send + Sized {
|
||||
/// Cryptographic identity of the peer
|
||||
type Identity: Sized;
|
||||
/// Type used to hold configuration for client sessions
|
||||
type ClientConfig: ClientConfig<Self>;
|
||||
/// Type used to sign various values
|
||||
@@ -53,7 +51,7 @@ pub trait Session: Send + Sized {
|
||||
fn handshake_data(&self) -> Option<Box<dyn Any>>;
|
||||
|
||||
/// Get the peer's identity, if available
|
||||
fn peer_identity(&self) -> Option<Self::Identity>;
|
||||
fn peer_identity(&self) -> Option<Box<dyn Any>>;
|
||||
|
||||
/// Get the 0-RTT keys if available (clients only)
|
||||
///
|
||||
|
||||
@@ -36,7 +36,6 @@ impl TlsSession {
|
||||
}
|
||||
|
||||
impl crypto::Session for TlsSession {
|
||||
type Identity = CertificateChain;
|
||||
type ClientConfig = Arc<rustls::ClientConfig>;
|
||||
type HmacKey = hmac::Key;
|
||||
type HandshakeTokenKey = hkdf::Prk;
|
||||
@@ -71,8 +70,10 @@ impl crypto::Session for TlsSession {
|
||||
}))
|
||||
}
|
||||
|
||||
fn peer_identity(&self) -> Option<CertificateChain> {
|
||||
self.inner.peer_certificates().map(|v| v.to_vec().into())
|
||||
fn peer_identity(&self) -> Option<Box<dyn Any>> {
|
||||
self.inner
|
||||
.peer_certificates()
|
||||
.map(|v| -> Box<dyn Any> { Box::new(CertificateChain::from(v.to_vec())) })
|
||||
}
|
||||
|
||||
fn early_crypto(&self) -> Option<(Self::HeaderKey, Self::PacketKey)> {
|
||||
|
||||
@@ -478,7 +478,11 @@ where
|
||||
}
|
||||
|
||||
/// Cryptographic identity of the peer
|
||||
pub fn peer_identity(&self) -> Option<S::Identity> {
|
||||
///
|
||||
/// The dynamic type returned is determined by the configured
|
||||
/// [`Session`](proto::crypto::Session). For the default `rustls` session, the return value can
|
||||
/// be [`downcast`](Box::downcast) to a [`CertificateChain`](crate::CertificateChain).
|
||||
pub fn peer_identity(&self) -> Option<Box<dyn Any>> {
|
||||
self.0
|
||||
.lock("peer_identity")
|
||||
.inner
|
||||
|
||||
Reference in New Issue
Block a user