Skip to main content

CipherSuite

Enum CipherSuite 

Source
#[non_exhaustive]
pub enum CipherSuite { Aes128CtrHmacSha256_80, Aes128CtrHmacSha256_64, Aes128CtrHmacSha256_32, Aes128GcmSha256_128, Aes256GcmSha512_128, Aes256CtrHmacSha512_80, Aes256CtrHmacSha512_64, Aes256CtrHmacSha512_32, }
Expand description

An SFrame cipher suite: the hash used for key derivation and the AEAD used for the frames.

The first five are the suites of RFC 9605 section 4.5. The three Aes256CtrHmacSha512 suites are the AES-256 counterparts of the AES-CTR construction that RFC 10079 registers (IANA “SFrame Cipher Suites” values 0x0006 to 0x0008, section 4.2), which the W3C Encoded Transform API lists in SFrameCipherSuite. The sizes below are the registry’s columns as RFC 10079 section 4.1 adds them (Nh, Nka, Nk, Nn, Nt).

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Aes128CtrHmacSha256_80

AES_128_CTR_HMAC_SHA256_80 (0x0001): AES-128-CTR with HMAC-SHA256, 80-bit tag.

§

Aes128CtrHmacSha256_64

AES_128_CTR_HMAC_SHA256_64 (0x0002): AES-128-CTR with HMAC-SHA256, 64-bit tag.

§

Aes128CtrHmacSha256_32

AES_128_CTR_HMAC_SHA256_32 (0x0003): AES-128-CTR with HMAC-SHA256, 32-bit tag.

§

Aes128GcmSha256_128

AES_128_GCM_SHA256_128 (0x0004): AES-128-GCM, keys derived with SHA-256.

§

Aes256GcmSha512_128

AES_256_GCM_SHA512_128 (0x0005): AES-256-GCM, keys derived with SHA-512.

§

Aes256CtrHmacSha512_80

AES_256_CTR_HMAC_SHA512_80 (0x0006): AES-256-CTR with HMAC-SHA512, 80-bit tag.

§

Aes256CtrHmacSha512_64

AES_256_CTR_HMAC_SHA512_64 (0x0007): AES-256-CTR with HMAC-SHA512, 64-bit tag.

§

Aes256CtrHmacSha512_32

AES_256_CTR_HMAC_SHA512_32 (0x0008): AES-256-CTR with HMAC-SHA512, 32-bit tag.

Implementations§

Source§

impl CipherSuite

Source

pub const ALL: [CipherSuite; 8]

Every suite this crate implements, in registry order.

Source

pub const fn id(self) -> u16

The suite’s value in the IANA “SFrame Cipher Suites” registry (RFC 9605 section 8.1). It is part of the key derivation labels.

Source

pub const fn from_id(id: u16) -> Option<Self>

The suite with this registry value, if this crate implements it. 0x0000 is reserved and 0xF000 to 0xFFFF are for private use: neither names a suite.

Source

pub const fn name(self) -> &'static str

The suite’s registered name, which is also its SFrameCipherSuite value in the W3C Encoded Transform API.

Source

pub const fn hash_len(self) -> usize

Hash.Nh: the output size in bytes of the suite’s hash function.

Source

pub const fn aes_ctr_key_len(self) -> Option<usize>

AEAD.Nka: the AES key size in bytes of a suite built on AES-CTR with HMAC; None for the GCM suites.

Source

pub const fn key_len(self) -> usize

AEAD.Nk: the size in bytes of the derived sframe_key. For the AES-CTR suites it is Nka + Nh (an encryption subkey and an authentication subkey). It is also the length an MLS exporter is asked for (RFC 9605 section 5.2).

Source

pub const fn nonce_len(self) -> usize

AEAD.Nn: the nonce size in bytes.

Source

pub const fn tag_len(self) -> usize

AEAD.Nt: the size in bytes of the authentication tag the suite appends.

Trait Implementations§

Source§

impl Clone for CipherSuite

Source§

fn clone(&self) -> Self

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 Copy for CipherSuite

Source§

impl Debug for CipherSuite

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for CipherSuite

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for CipherSuite

Source§

impl From<CipherSuite> for u16

Source§

fn from(suite: CipherSuite) -> Self

Converts to this type from the input type.
Source§

impl FromStr for CipherSuite

Source§

fn from_str(name: &str) -> Result<Self, Self::Err>

Parses a registered name, exactly as registered.

Source§

type Err = UnknownCipherSuite

The associated error which can be returned from parsing.
Source§

impl Hash for CipherSuite

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for CipherSuite

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CipherSuite

Source§

impl TryFrom<u16> for CipherSuite

Source§

type Error = UnknownCipherSuite

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

fn try_from(id: u16) -> Result<Self, Self::Error>

Performs the conversion.

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> Same for T

Source§

type Output = T

Should always be Self
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.