pub struct DekBuffer { /* private fields */ }Expand description
DEK 安全缓冲区
内部用 Zeroizing<Vec<u8>> 包装 DEK 明文,Drop 时自动清零。
Implementations§
Source§impl DekBuffer
impl DekBuffer
Sourcepub fn from_slice(slice: &[u8]) -> DekBuffer
pub fn from_slice(slice: &[u8]) -> DekBuffer
从字节切片创建
Sourcepub fn encrypt(
&self,
plaintext: &[u8],
algo: EncryptionAlgo,
) -> Result<Vec<u8>, CryptoError>
pub fn encrypt( &self, plaintext: &[u8], algo: EncryptionAlgo, ) -> Result<Vec<u8>, CryptoError>
用 DEK 加密数据
支持 AES-256-GCM,其他算法返回 CryptoError。
栈上临时 key 拷贝在用毕后清零(2026-09-14 安全审计修复)。
Sourcepub fn decrypt(
&self,
ciphertext: &[u8],
algo: EncryptionAlgo,
) -> Result<Vec<u8>, CryptoError>
pub fn decrypt( &self, ciphertext: &[u8], algo: EncryptionAlgo, ) -> Result<Vec<u8>, CryptoError>
用 DEK 解密数据
栈上临时 key 拷贝在用毕后清零(2026-09-14 安全审计修复)。
Auto Trait Implementations§
impl Freeze for DekBuffer
impl RefUnwindSafe for DekBuffer
impl Send for DekBuffer
impl Sync for DekBuffer
impl Unpin for DekBuffer
impl UnsafeUnpin for DekBuffer
impl UnwindSafe for DekBuffer
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
Converts
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> ⓘ
Converts
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