Skip to main content

Aes128CcmAny

Struct Aes128CcmAny 

Source
pub struct Aes128CcmAny { /* private fields */ }
Expand description

AES-128-CCM,标签长度运行时可配的全参数实例(RFC 3610 完整参数 空间:M ∈ {4,6,8,10,12,14,16},nonce 7..=13 字节)。

M=4/6 的完整性标签弱于 RFC 3610 作者建议(≥ 8),仅为兼容既有 协议提供;TLS 批准套件面(SP 800-52r2)只使用 M=16(见模块头)。

Implementations§

Source§

impl Aes128CcmAny

Source

pub const KEY_LEN: usize = 16

密钥字节数。

Source

pub const APPROVAL: Approval = crate::Approval::Approved

本算法在 FIPS 140-3 下的批准状态:SP 800-38C 对全部受支持 M 值批准(TLS 批准套件面不含 M=8,见模块头)。

Source

pub fn new(key: &[u8; 16], tag_len: usize) -> Result<Self, Error>

构造:tag_len 必须 ∈ {4,6,8,10,12,14,16},否则返回 Error::InvalidInput

Source

pub fn seal( &self, nonce: &[u8], aad: &[u8], plaintext: &[u8], ) -> Result<Vec<u8>, Error>

加密:返回 密文 || 标签(标签 tag_len 字节)。

nonce 长度必须为 7..=13 字节;长度域限制见内部 check_length_domain

Source

pub fn open( &self, nonce: &[u8], aad: &[u8], ct_and_tag: &[u8], ) -> Result<Vec<u8>, Error>

解密并验证;失败统一返回 Error::VerificationFailed

Trait Implementations§

Source§

impl Clone for Aes128CcmAny

Source§

fn clone(&self) -> Aes128CcmAny

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Aes128CcmAny

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.