pub struct SessionCrypto { /* private fields */ }mysql or postgres or sqlite or valkey only.Expand description
AES-256-GCM encryption configuration with optional key rotation.
Implementations§
Source§impl SessionCrypto
impl SessionCrypto
Sourcepub fn new(key: [u8; 32]) -> Self
pub fn new(key: [u8; 32]) -> Self
Create a new crypto config with the given 32-byte key. Uses
SystemRng for nonce generation; tests under DST should use
SessionCrypto::with_rng to inject a deterministic RNG.
Sourcepub fn with_rng(self, rng: Arc<dyn SecureRng>) -> Self
pub fn with_rng(self, rng: Arc<dyn SecureRng>) -> Self
Swap the RNG used for nonce generation. Production code keeps the
default SystemRng; DST suites pass a seeded MockRng to drive
nonce sequences deterministically.
Sourcepub fn with_previous_key(self, key: [u8; 32]) -> Self
pub fn with_previous_key(self, key: [u8; 32]) -> Self
Enable key rotation: on decrypt, try the current key first, then this previous key as a fallback.
Sourcepub fn encrypt(&self, plaintext: &[u8]) -> Result<Vec<u8>, CryptoError>
pub fn encrypt(&self, plaintext: &[u8]) -> Result<Vec<u8>, CryptoError>
Encrypt plaintext with AES-256-GCM. Returns nonce || ciphertext.
Each call generates a random 96-bit (12-byte) nonce. The collision
probability is negligible (~2^-96 per pair), which is safe for up to
~2^32 encryptions per key, far beyond typical session store volumes.
The aes-gcm crate performs constant-time authentication tag comparison
internally during decryption.
Trait Implementations§
Source§impl Clone for SessionCrypto
impl Clone for SessionCrypto
Source§fn clone(&self) -> SessionCrypto
fn clone(&self) -> SessionCrypto
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SessionCrypto
impl !RefUnwindSafe for SessionCrypto
impl Send for SessionCrypto
impl Sync for SessionCrypto
impl Unpin for SessionCrypto
impl UnsafeUnpin for SessionCrypto
impl !UnwindSafe for SessionCrypto
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.