Skip to main content

qssl/integrations/
mod.rs

1//! Integration modules for other protocols
2
3#[cfg(feature = "qssh")]
4pub mod qssh;
5
6/// Common integration traits
7pub mod traits {
8    use async_trait::async_trait;
9    use serde::{Serialize, Deserialize};
10
11    /// Transport integration trait
12    #[async_trait]
13    pub trait TransportIntegration: Send + Sync {
14        /// Send data
15        async fn send_data(&self, data: &[u8]) -> Result<(), Box<dyn std::error::Error>>;
16
17        /// Receive data
18        async fn recv_data(&self) -> Result<Vec<u8>, Box<dyn std::error::Error>>;
19
20        /// Check if connected
21        fn is_connected(&self) -> bool;
22    }
23
24    /// Session management trait
25    #[async_trait]
26    pub trait SessionIntegration: Send + Sync {
27        /// Store session
28        async fn store_session(&self, id: &[u8], data: &[u8]) -> Result<(), Box<dyn std::error::Error>>;
29
30        /// Retrieve session
31        async fn get_session(&self, id: &[u8]) -> Result<Option<Vec<u8>>, Box<dyn std::error::Error>>;
32
33        /// Remove session
34        async fn remove_session(&self, id: &[u8]) -> Result<bool, Box<dyn std::error::Error>>;
35    }
36
37    /// Key management trait
38    pub trait KeyIntegration: Send + Sync {
39        /// Derive session keys
40        fn derive_keys(&self, master_secret: &[u8]) -> Result<SessionKeys, Box<dyn std::error::Error>>;
41
42        /// Export key material
43        fn export_keying_material(&self, label: &str, length: usize) -> Result<Vec<u8>, Box<dyn std::error::Error>>;
44    }
45
46    /// Session keys structure
47    #[derive(Debug, Clone)]
48    pub struct SessionKeys {
49        pub client_write_key: Vec<u8>,
50        pub server_write_key: Vec<u8>,
51        pub client_write_iv: Vec<u8>,
52        pub server_write_iv: Vec<u8>,
53    }
54}