KeyConfig

Struct KeyConfig 

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

The key configuration of a server. This can be used by both client and server. An important invariant of this structure is that it does not include any combination of KEM, KDF, and AEAD that is not supported.

Implementations§

Source§

impl KeyConfig

Source

pub fn new( key_id: u8, kem: Kem, symmetric: Vec<SymmetricSuite>, ) -> Result<Self, Error>

Construct a configuration for the server side.

§Panics

If the configurations don’t include a supported configuration.

Source

pub fn derive( key_id: u8, kem: Kem, symmetric: Vec<SymmetricSuite>, ikm: &[u8], ) -> Result<Self, Error>

Derive a configuration for the server side from input keying material, using the DeriveKeyPair functionality of the HPKE KEM defined here: https://www.ietf.org/archive/id/draft-irtf-cfrg-hpke-12.html#section-4

§Panics

If the configurations don’t include a supported configuration.

Source

pub fn encode_list(list: &[impl AsRef<Self>]) -> Result<Vec<u8>, Error>

Encode a list of key configurations.

This produces the key configuration format that is used for the “application/ohttp-keys” media type. Each item in the list is written as per encode().

§Panics

Not as a result of this function.

Source

pub fn encode(&self) -> Result<Vec<u8>, Error>

Encode into a wire format. This shares a format with the core of ECH:

opaque HpkePublicKey[Npk];
uint16 HpkeKemId;  // Defined in I-D.irtf-cfrg-hpke
uint16 HpkeKdfId;  // Defined in I-D.irtf-cfrg-hpke
uint16 HpkeAeadId; // Defined in I-D.irtf-cfrg-hpke

struct {
  HpkeKdfId kdf_id;
  HpkeAeadId aead_id;
} ECHCipherSuite;

struct {
  uint8 key_id;
  HpkeKemId kem_id;
  HpkePublicKey public_key;
  ECHCipherSuite cipher_suites<4..2^16-4>;
} ECHKeyConfig;
§Panics

Not as a result of this function.

Source

pub fn decode(encoded_config: &[u8]) -> Result<Self, Error>

Construct a configuration from the encoded server configuration. The format of encoded_config is the output of Self::encode.

Source

pub fn decode_list(encoded_list: &[u8]) -> Result<Vec<Self>, Error>

Decode a list of key configurations. This only returns the valid and supported key configurations; unsupported configurations are dropped silently.

Source

pub fn select(&self, sym: SymmetricSuite) -> Result<HpkeConfig, Error>

Select creates a new configuration that contains the identified symmetric suite.

§Errors

If the given suite is not supported by this configuration.

Trait Implementations§

Source§

impl AsRef<KeyConfig> for KeyConfig

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for KeyConfig

Source§

fn clone(&self) -> KeyConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for KeyConfig

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V