pub struct CbcHmacEncryptor<C: BlockCipher + BlockEncryptMut + BlockDecryptMut + KeyInit, const KEY_LEN: usize> { /* private fields */ }Expand description
CBC-HMAC 加密器:C 为块密码,KEY_LEN 为其密钥长度(字节)。
直接在结构体里持有派生好的 EtM 密钥对(密文密钥 + MAC 密钥,均 Drop 清零), 因此每次调用不再重复派生 MAC 密钥。
Implementations§
Source§impl<C, const KEY_LEN: usize> CbcHmacEncryptor<C, KEY_LEN>
impl<C, const KEY_LEN: usize> CbcHmacEncryptor<C, KEY_LEN>
Sourcepub fn with_names(
key: [u8; KEY_LEN],
identifier: &'static str,
label: &'static str,
) -> Self
pub fn with_names( key: [u8; KEY_LEN], identifier: &'static str, label: &'static str, ) -> Self
具名构造:identifier 为注册表标识,label 为错误消息里的算法名。
Sourcepub fn with_names_from_slice(
key: &[u8],
identifier: &'static str,
label: &'static str,
) -> Result<Self>
pub fn with_names_from_slice( key: &[u8], identifier: &'static str, label: &'static str, ) -> Result<Self>
从切片构造;长度不符返回 Error::InvalidKeyLength。
Source§impl CbcHmacEncryptor<Aes256, 32>
impl CbcHmacEncryptor<Aes256, 32>
Sourcepub const IDENTIFIER: &'static str = "aes-256-cbc-hmac"
pub const IDENTIFIER: &'static str = "aes-256-cbc-hmac"
注册表标识。
Sourcepub fn from_slice(key: &[u8]) -> Result<Self>
pub fn from_slice(key: &[u8]) -> Result<Self>
从切片构造;长度不符返回 Error::InvalidKeyLength。
Source§impl CbcHmacEncryptor<Camellia256, 32>
impl CbcHmacEncryptor<Camellia256, 32>
Sourcepub const IDENTIFIER: &'static str = "camellia-256-cbc-hmac"
pub const IDENTIFIER: &'static str = "camellia-256-cbc-hmac"
注册表标识。
Sourcepub fn from_slice(key: &[u8]) -> Result<Self>
pub fn from_slice(key: &[u8]) -> Result<Self>
从切片构造;长度不符返回 Error::InvalidKeyLength。
Source§impl CbcHmacEncryptor<Aria256, 32>
impl CbcHmacEncryptor<Aria256, 32>
Sourcepub const IDENTIFIER: &'static str = "aria-256-cbc-hmac"
pub const IDENTIFIER: &'static str = "aria-256-cbc-hmac"
注册表标识。
Sourcepub fn from_slice(key: &[u8]) -> Result<Self>
pub fn from_slice(key: &[u8]) -> Result<Self>
从切片构造;长度不符返回 Error::InvalidKeyLength。
Source§impl CbcHmacEncryptor<Kuznyechik, 32>
impl CbcHmacEncryptor<Kuznyechik, 32>
Sourcepub const IDENTIFIER: &'static str = "kuznyechik-256-cbc-hmac"
pub const IDENTIFIER: &'static str = "kuznyechik-256-cbc-hmac"
注册表标识。
Sourcepub fn from_slice(key: &[u8]) -> Result<Self>
pub fn from_slice(key: &[u8]) -> Result<Self>
从切片构造;长度不符返回 Error::InvalidKeyLength。
Source§impl CbcHmacEncryptor<Threefish512, 64>
impl CbcHmacEncryptor<Threefish512, 64>
Sourcepub const IDENTIFIER: &'static str = "threefish-512-cbc-hmac"
pub const IDENTIFIER: &'static str = "threefish-512-cbc-hmac"
注册表标识。
Sourcepub fn from_slice(key: &[u8]) -> Result<Self>
pub fn from_slice(key: &[u8]) -> Result<Self>
从切片构造;长度不符返回 Error::InvalidKeyLength。
Source§impl CbcHmacEncryptor<Sm4, 16>
impl CbcHmacEncryptor<Sm4, 16>
Sourcepub const IDENTIFIER: &'static str = "sm4-cbc"
pub const IDENTIFIER: &'static str = "sm4-cbc"
注册表标识。
Sourcepub fn from_slice(key: &[u8]) -> Result<Self>
pub fn from_slice(key: &[u8]) -> Result<Self>
从切片构造;长度不符返回 Error::InvalidKeyLength。
Trait Implementations§
Source§impl<C, const KEY_LEN: usize> Debug for CbcHmacEncryptor<C, KEY_LEN>
只打印标识符——密钥材质不出现在 Debug 里。
impl<C, const KEY_LEN: usize> Debug for CbcHmacEncryptor<C, KEY_LEN>
只打印标识符——密钥材质不出现在 Debug 里。
Source§impl<C, const KEY_LEN: usize> Identified for CbcHmacEncryptor<C, KEY_LEN>
impl<C, const KEY_LEN: usize> Identified for CbcHmacEncryptor<C, KEY_LEN>
fn identifier(&self) -> &str
Source§impl<C, const KEY_LEN: usize> SymmetricCipher for CbcHmacEncryptor<C, KEY_LEN>
impl<C, const KEY_LEN: usize> SymmetricCipher for CbcHmacEncryptor<C, KEY_LEN>
Auto Trait Implementations§
impl<C, const KEY_LEN: usize> Freeze for CbcHmacEncryptor<C, KEY_LEN>
impl<C, const KEY_LEN: usize> RefUnwindSafe for CbcHmacEncryptor<C, KEY_LEN>
impl<C, const KEY_LEN: usize> Send for CbcHmacEncryptor<C, KEY_LEN>
impl<C, const KEY_LEN: usize> Sync for CbcHmacEncryptor<C, KEY_LEN>
impl<C, const KEY_LEN: usize> Unpin for CbcHmacEncryptor<C, KEY_LEN>
impl<C, const KEY_LEN: usize> UnsafeUnpin for CbcHmacEncryptor<C, KEY_LEN>
impl<C, const KEY_LEN: usize> UnwindSafe for CbcHmacEncryptor<C, KEY_LEN>
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> 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> IntoCollection<T> for T
impl<T> IntoCollection<T> for T
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> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);