pub struct GroupKeys<C: Config, const K: usize = 15, const M: usize = 20> { /* private fields */ }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>
impl<C: Config, const K: usize, const M: usize> GroupKeys<C, K, M>
Sourcepub const CHECK: ()
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.
Sourcepub const fn max_groups_per_fabric(&self) -> usize
pub const fn max_groups_per_fabric(&self) -> usize
MaxGroupsPerFabric (§11.2.6.2).
Sourcepub const fn max_key_sets_per_fabric(&self) -> usize
pub const fn max_key_sets_per_fabric(&self) -> usize
MaxGroupKeysPerFabric (§11.2.6.3).
Sourcepub fn key_sets(&self) -> &[GroupKeySet]
pub fn key_sets(&self) -> &[GroupKeySet]
Every key set, for a device about to persist them.
Sourcepub fn map(&self) -> &[(FabricIndex, GroupId, KeySetId)]
pub fn map(&self) -> &[(FabricIndex, GroupId, KeySetId)]
The GroupKeyMap entries (§11.2.6.1).
Sourcepub fn write_key_set(&mut self, set: GroupKeySet) -> Result<(), Status>
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”.
Sourcepub fn key_set(&self, fabric: FabricIndex, id: KeySetId) -> Option<&GroupKeySet>
pub fn key_set(&self, fabric: FabricIndex, id: KeySetId) -> Option<&GroupKeySet>
One key set, if this fabric has it.
Sourcepub fn remove_key_set(
&mut self,
fabric: FabricIndex,
id: KeySetId,
) -> Result<(), Status>
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).
Sourcepub fn map_group(
&mut self,
fabric: FabricIndex,
group: GroupId,
key_set: KeySetId,
) -> Result<(), Status>
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.
Sourcepub fn replace_map(
&mut self,
fabric: FabricIndex,
entries: &[(GroupId, KeySetId)],
) -> Result<(), Status>
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.
Sourcepub fn remove_fabric(&mut self, fabric: FabricIndex)
pub fn remove_fabric(&mut self, fabric: FabricIndex)
Forgets everything one fabric installed — what RemoveFabric must do.
Sourcepub fn sending_key(
&self,
fabric: FabricIndex,
compressed: CompressedFabricId,
group: GroupId,
now: Option<Instant>,
) -> Result<OperationalKey>
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.
Sourcepub fn receiving_keys<const N: usize>(
&self,
compressed: impl Fn(FabricIndex) -> Option<CompressedFabricId>,
session_id: u16,
) -> Vec<OperationalKey, N>
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.