use core::time::Duration;
#[cfg(not(feature = "std"))]
use alloc::{boxed::Box, sync::Arc, vec::Vec};
#[cfg(feature = "std")]
use std::sync::Arc;
use crate::crypto::aead::RuntimeAead;
use crate::crypto::profiles::CryptoProvider;
use crate::crypto::x509::policy::CertificateValidation;
use crate::crypto::x509::store::CertificateTrust;
use crate::transport::handshake::{
HandshakeError, HandshakeKeyManager, HandshakeProtocolKind, ServerHandshakeProtocol, TcpHandshakeState,
};
use crate::transport::TransportResult;
use crate::x509::Certificate;
#[cfg(feature = "x509")]
pub trait EncryptedProtocolState {
type CryptoProvider: CryptoProvider + Send + Sync + 'static;
fn to_encryptor_ref(&self) -> TransportResult<&RuntimeAead>;
fn to_decryptor_ref(&self) -> TransportResult<&RuntimeAead>;
fn to_handshake_state(&self) -> TcpHandshakeState;
fn set_handshake_state(&mut self, state: TcpHandshakeState);
fn to_server_certificate_ref(&self) -> Option<&Certificate>;
fn to_server_certificate_arc(&self) -> Option<Arc<Certificate>> {
None
}
fn set_symmetric_key(&mut self, key: RuntimeAead);
fn unset_symmetric_key(&mut self);
fn set_peer_certificate(&mut self, _cert: Certificate);
fn to_max_cleartext_envelope(&self) -> Option<usize> {
None
}
fn to_max_encrypted_envelope(&self) -> Option<usize> {
None
}
fn is_client_validators_present(&self) -> bool {
false
}
fn to_handshake_protocol_kind(&self) -> HandshakeProtocolKind {
HandshakeProtocolKind::default()
}
fn to_key_manager_ref(&self) -> Option<&Arc<HandshakeKeyManager<Self::CryptoProvider>>> {
None
}
fn to_client_certificate_ref(&self) -> Option<&Arc<Certificate>> {
None
}
fn to_trust_store_ref(&self) -> Option<&Arc<dyn CertificateTrust>> {
None
}
fn to_server_handshake_mut(
&mut self,
) -> &mut Option<Box<dyn ServerHandshakeProtocol<Error = HandshakeError> + Send + Sync>>;
fn to_handshake_timeout(&self) -> Duration {
Duration::from_secs(1)
}
fn to_client_validators_ref(&self) -> Option<&Arc<Vec<Arc<dyn CertificateValidation>>>> {
None
}
}