pub struct SFrameSession { /* private fields */ }Expand description
An SFrame session bound to one MLS epoch.
A new session must be created whenever the MLS group commits (epoch changes) — the old base key becomes unreachable and all per-sender keys are rotated automatically.
Owns the per-leaf encryptor state for this epoch: repeated calls to
encryptor for the same leaf_index return a handle
to the same counter, never a fresh one, so callers cannot accidentally
reuse a (key, KID, CTR) nonce by recreating a handle (e.g. one per
thread, or on every request).
Implementations§
Source§impl SFrameSession
impl SFrameSession
Sourcepub fn new(base_key: [u8; 32], epoch: u64, suite: CipherSuite) -> SFrameSession
pub fn new(base_key: [u8; 32], epoch: u64, suite: CipherSuite) -> SFrameSession
Creates a session from a raw 32-byte base key.
Prefer from_mls when an MlsContext is
available; this constructor is mainly for testing.
Sourcepub fn from_mls(
mls: &MlsContext,
label: &str,
suite: CipherSuite,
) -> Result<SFrameSession, SFrameError>
pub fn from_mls( mls: &MlsContext, label: &str, suite: CipherSuite, ) -> Result<SFrameSession, SFrameError>
Derives a session from the current MLS group state.
Calls MLS.ExportSecret(label, context=epoch_be8, length=32) to
obtain the base key, then stores it alongside the current epoch and
ciphersuite.
label is application-defined (e.g. "gbp/sframe v1").
Sourcepub fn suite(&self) -> CipherSuite
pub fn suite(&self) -> CipherSuite
Returns the active ciphersuite.
Sourcepub fn encryptor(&self, leaf_index: u32) -> SFrameEncryptor
pub fn encryptor(&self, leaf_index: u32) -> SFrameEncryptor
Returns a sender-side encryptor handle for leaf_index.
The returned SFrameEncryptor holds the derived key+salt for this
sender and shares its counter with every other handle returned for
the same leaf_index on this session - calling this repeatedly (one
per thread, one per request, …) is safe and will never produce two
independent counters for the same KID.
Sourcepub fn decryptor(&self) -> SFrameDecryptor
pub fn decryptor(&self) -> SFrameDecryptor
Creates a receiver-side decryptor for this epoch.
The SFrameDecryptor lazily derives per-sender keys as new KIDs
arrive, and maintains an independent 1024-entry replay window per sender.
Auto Trait Implementations§
impl !Freeze for SFrameSession
impl RefUnwindSafe for SFrameSession
impl Send for SFrameSession
impl Sync for SFrameSession
impl Unpin for SFrameSession
impl UnsafeUnpin for SFrameSession
impl UnwindSafe for SFrameSession
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more