pub struct Session {
pub id: u64,
pub rng: SeedRng,
pub data_key: [u8; 32],
pub packet_counter: u64,
pub active: bool,
pub key_index: u64,
}Expand description
An established SRX session holding all runtime state.
Fields§
§id: u64Session identifier.
rng: SeedRngCurrent seed RNG (shared with peer).
data_key: [u8; 32]Current data encryption key.
packet_counter: u64Packet counter for this session.
active: boolWhether the session is still active.
key_index: u64Key derivation epoch (incremented on each re-key).
Implementations§
Source§impl Session
impl Session
Sourcepub fn from_master_secret(
id: u64,
master_key: &[u8; 32],
timestamp: u64,
session_nonce: &[u8],
) -> Result<Self>
pub fn from_master_secret( id: u64, master_key: &[u8; 32], timestamp: u64, session_nonce: &[u8], ) -> Result<Self>
Build session state from K_master and handshake parameters (matches peer’s derive_initial_seed).
Sourcepub fn new(id: u64, seed: [u8; 32], data_key: [u8; 32]) -> Self
pub fn new(id: u64, seed: [u8; 32], data_key: [u8; 32]) -> Self
Create a new session from handshake results.
Sourcepub fn next_packet_counter(&mut self) -> u64
pub fn next_packet_counter(&mut self) -> u64
Increment the packet counter and return the new value.
Sourcepub fn rekey(&mut self) -> Result<[u8; 32]>
pub fn rekey(&mut self) -> Result<[u8; 32]>
Rotate the data key using KDF.
Derives data_key[key_index+1] = HKDF(seed, key_index+1) and increments
key_index. Returns the new key.
Sourcepub fn encrypt_with_pipeline(
&mut self,
pipeline: &AeadPipeline,
plaintext: &[u8],
) -> Result<Vec<u8>>
pub fn encrypt_with_pipeline( &mut self, pipeline: &AeadPipeline, plaintext: &[u8], ) -> Result<Vec<u8>>
Encrypt application payload using the parallel AEAD pool and a KDF-derived nonce.
Advances Session::packet_counter and derives nonce = HKDF(seed ‖ counter).
Sourcepub fn decrypt_with_pipeline(
&self,
pipeline: &AeadPipeline,
nonce: [u8; 12],
ciphertext: Vec<u8>,
) -> Result<Vec<u8>>
pub fn decrypt_with_pipeline( &self, pipeline: &AeadPipeline, nonce: [u8; 12], ciphertext: Vec<u8>, ) -> Result<Vec<u8>>
Decrypt using an explicit nonce (e.g. derived on receive from frame metadata or inner payload).
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl UnwindSafe for Session
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request