Skip to main content

GroupKeys

Struct GroupKeys 

Source
pub struct GroupKeys<C: Config, const K: usize = 15, const M: usize = 20> { /* private fields */ }
Available on crate feature rustcrypto only.
Expand description

The per-fabric group state of §11.2: the key sets, and which key set each group uses.

K bounds the key sets across every fabric and M the group-to-key-set map. The per-fabric quotas §11.2.6.3’s MaxGroupKeysPerFabric and §11.2.6.2’s MaxGroupsPerFabric report come from Config, and GroupKeys::CHECK refuses at compile time a K or M too small to give every fabric its share — which is the only way those two attributes can be the promise the specification says they are rather than a pair of numbers typed beside the table.

Implementations§

Source§

impl<C: Config, const K: usize, const M: usize> GroupKeys<C, K, M>

Source

pub const CHECK: ()

Compile-time proof that both tables can keep §2.11.1.2’s promises.

at least four groups per fabric … at least three group keys per fabric

The quotas are what stop the first fabric to provision from filling the table; this is what stops the quotas from promising room that is not there.

Source

pub fn new() -> Self

An empty table.

Source

pub const fn max_groups_per_fabric(&self) -> usize

MaxGroupsPerFabric (§11.2.6.2).

Source

pub const fn max_key_sets_per_fabric(&self) -> usize

MaxGroupKeysPerFabric (§11.2.6.3).

Source

pub fn key_sets(&self) -> &[GroupKeySet]

Every key set, for a device about to persist them.

Source

pub fn map(&self) -> &[(FabricIndex, GroupId, KeySetId)]

The GroupKeyMap entries (§11.2.6.1).

Source

pub fn write_key_set(&mut self, set: GroupKeySet) -> Result<(), Status>

Installs or replaces a key set — §11.2.7.1’s KeySetWrite.

Any update of the key set, including a partial update, SHALL remove all previous keys in the set, however many were defined.

So this replaces rather than merges, which is what makes the command idempotent and the administrator “always the source of truth”.

Source

pub fn key_set(&self, fabric: FabricIndex, id: KeySetId) -> Option<&GroupKeySet>

One key set, if this fabric has it.

Source

pub fn remove_key_set( &mut self, fabric: FabricIndex, id: KeySetId, ) -> Result<(), Status>

Removes a key set — §11.2.7.4’s KeySetRemove.

This command SHALL fail with an INVALID_COMMAND status code back to the initiator if the GroupKeySetID being removed is 0, which is the key set associated with the Identity Protection Key (IPK).

Source

pub fn map_group( &mut self, fabric: FabricIndex, group: GroupId, key_set: KeySetId, ) -> Result<(), Status>

Maps a group to a key set — one entry of §11.2.6.1’s GroupKeyMap.

Source

pub fn replace_map( &mut self, fabric: FabricIndex, entries: &[(GroupId, KeySetId)], ) -> Result<(), Status>

Replaces one fabric’s whole GroupKeyMap, which is what a list write does.

Source

pub fn remove_fabric(&mut self, fabric: FabricIndex)

Forgets everything one fabric installed — what RemoveFabric must do.

Source

pub fn sending_key( &self, fabric: FabricIndex, compressed: CompressedFabricId, group: GroupId, now: Option<Instant>, ) -> Result<OperationalKey>

The key a sender encrypts a message to group with (§4.16.2 step 1).

Obtain, for the given GroupKeySetID, the current Operational Group Key as the Encryption Key, and the associated Group Session ID. If no key is found for the given GroupKeySetID, security processing SHALL fail and no further security processing SHALL be done on this message.

Source

pub fn receiving_keys<const N: usize>( &self, compressed: impl Fn(FabricIndex) -> Option<CompressedFabricId>, session_id: u16, ) -> Vec<OperationalKey, N>

Every key a receiver should try for a message that named session_id (§4.17.3.6).

On receipt of a message of Group Session Type, all valid, installed, operational group key candidates referenced by the given Group Session ID SHALL be attempted until authentication is passed or there are no more operational group keys to try.

Every installed epoch key, not just the current one: §4.17.3.1 has a receiver “accept the use of any key derived from one of the currently installed epoch keys … regardless of whether the start time for the key is in the future or the past”, because the sender’s clock is not this node’s.

Trait Implementations§

Source§

impl<C: Config, const K: usize, const M: usize> Capacity for GroupKeys<C, K, M>

Source§

const PER_FABRIC: usize = C::GROUP_KEYS_PER_FABRIC

§11.2.6.3’s MaxGroupKeysPerFabric.

Source§

const TOTAL: usize = K

Total slots, across every fabric.
Source§

impl<C: Debug + Config, const K: usize, const M: usize> Debug for GroupKeys<C, K, M>

Source§

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

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

impl<C: Config, const K: usize, const M: usize> Default for GroupKeys<C, K, M>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<C, const K: usize, const M: usize> Forget for GroupKeys<C, K, M>

§

impl<C, const K: usize, const M: usize> Freeze for GroupKeys<C, K, M>

§

impl<C, const K: usize, const M: usize> Move for GroupKeys<C, K, M>

§

impl<C, const K: usize, const M: usize> RefUnwindSafe for GroupKeys<C, K, M>

§

impl<C, const K: usize, const M: usize> Send for GroupKeys<C, K, M>

§

impl<C, const K: usize, const M: usize> Sync for GroupKeys<C, K, M>

§

impl<C, const K: usize, const M: usize> Unpin for GroupKeys<C, K, M>

§

impl<C, const K: usize, const M: usize> UnsafeUnpin for GroupKeys<C, K, M>

§

impl<C, const K: usize, const M: usize> UnwindSafe for GroupKeys<C, K, M>

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> 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, 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.