pub struct SenderKeyIdLayout { /* private fields */ }Expand description
The KID layout of the sender-keys scheme (RFC 9605 section 5.1, Figure 7).
64-R bits R bits
<---------------> <------------>
+-----------------+--------------+
| Key Generation | Ratchet Step |
+-----------------+--------------+KID = (key_generation << R) + (ratchet_step % (1 << R)). R is set by the application;
every receiver of a sender has to know the sender’s R.
Implementations§
Source§impl SenderKeyIdLayout
impl SenderKeyIdLayout
Sourcepub fn new(ratchet_bits: u32) -> Result<Self>
pub fn new(ratchet_bits: u32) -> Result<Self>
A layout with ratchet_bits (R) bits of ratchet step: 0 to 64.
Sourcepub const fn ratchet_bits(&self) -> u32
pub const fn ratchet_bits(&self) -> u32
R: the number of low-order bits that carry the ratchet step.
Sourcepub fn key_id(&self, key_generation: u64, ratchet_step: u64) -> Result<u64>
pub fn key_id(&self, key_generation: u64, ratchet_step: u64) -> Result<u64>
The KID of key_generation at ratchet_step. Only the low R bits of the step are
sent; the generation has to fit the remaining 64 - R.
Sourcepub const fn split(&self, kid: u64) -> SenderKeyId
pub const fn split(&self, kid: u64) -> SenderKeyId
The key generation and the low R bits of the ratchet step a KID carries.
Sourcepub const fn steps_between(&self, from_step: u64, ratchet_step: u64) -> u64
pub const fn steps_between(&self, from_step: u64, ratchet_step: u64) -> u64
How many ratchet steps lie from a key at from_step to the one a KID with
ratchet_step in its low bits names, counting forward modulo 1 << R.
Trait Implementations§
Source§impl Clone for SenderKeyIdLayout
impl Clone for SenderKeyIdLayout
impl Copy for SenderKeyIdLayout
Source§impl Debug for SenderKeyIdLayout
impl Debug for SenderKeyIdLayout
impl Eq for SenderKeyIdLayout
Source§impl Hash for SenderKeyIdLayout
impl Hash for SenderKeyIdLayout
Source§impl PartialEq for SenderKeyIdLayout
impl PartialEq for SenderKeyIdLayout
impl StructuralPartialEq for SenderKeyIdLayout
Auto Trait Implementations§
impl Forget for SenderKeyIdLayout
impl Freeze for SenderKeyIdLayout
impl Move for SenderKeyIdLayout
impl RefUnwindSafe for SenderKeyIdLayout
impl Send for SenderKeyIdLayout
impl Sync for SenderKeyIdLayout
impl Unpin for SenderKeyIdLayout
impl UnsafeUnpin for SenderKeyIdLayout
impl UnwindSafe for SenderKeyIdLayout
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more