pub struct Poly1305 { /* private fields */ }Expand description
Poly1305 MAC state.
Holds the accumulator acc, the precomputed r (and r * 5 for
each limb, to absorb the * 5 mod p of the lazy reduction in the
inner loop), the tag-finalisation key s, and a 16-byte buffer
for handling messages whose length is not a multiple of 16.
Internally:
r[0..5]:rin 5 26-bit limbss[0..4]: the second half of the one-time key as 4 LE u32sacc[0..5]: accumulator in 5 26-bit limbsbuffer: up to 16 bytes of pending databuf_pos: 0..=16
Implementations§
Source§impl Poly1305
impl Poly1305
Sourcepub fn new(key: &[u8; 32]) -> Self
pub fn new(key: &[u8; 32]) -> Self
Initialise Poly1305 with a 32-byte one-time key key = r ‖ s.
r is clamped per RFC 8439 §2.5: bytes 3, 7, 11, 15 have
their top 4 bits cleared (& 0x0f) and bytes 4, 8, 12 have
their low 2 bits cleared (& 0xfc).
Sourcepub fn update(&mut self, data: &[u8])
pub fn update(&mut self, data: &[u8])
Absorb additional data into the accumulator.
Buffers up to 15 leftover bytes between calls so that arbitrary update sizes work the same as one big call.
Auto Trait Implementations§
impl Freeze for Poly1305
impl RefUnwindSafe for Poly1305
impl Send for Poly1305
impl Sync for Poly1305
impl Unpin for Poly1305
impl UnsafeUnpin for Poly1305
impl UnwindSafe for Poly1305
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