pub struct MacCtx { /* private fields */ }Expand description
Stateful MAC context (EVP_MAC_CTX*).
!Clone — use fork() to duplicate mid-stream state.
All stateful operations require &mut self.
Implementations§
Source§impl MacCtx
impl MacCtx
Sourcepub fn new(alg: &MacAlg) -> Result<Self, ErrorStack>
pub fn new(alg: &MacAlg) -> Result<Self, ErrorStack>
Create a new (uninitialised) MAC context from an algorithm descriptor.
Call MacCtx::init with a key before feeding data.
§Errors
Sourcepub fn init(
&mut self,
key: &[u8],
params: Option<&Params<'_>>,
) -> Result<(), ErrorStack>
pub fn init( &mut self, key: &[u8], params: Option<&Params<'_>>, ) -> Result<(), ErrorStack>
Initialise (or re-initialise) with a key and optional parameters.
key is always copied into the MAC context by EVP_MAC_init.
HMAC additionally pads the key into IPAD/OPAD. The copy is unavoidable.
§Errors
Sourcepub fn update(&mut self, data: &[u8]) -> Result<(), ErrorStack>
pub fn update(&mut self, data: &[u8]) -> Result<(), ErrorStack>
Feed data into the ongoing MAC computation.
§Errors
Sourcepub fn finish(&mut self, out: &mut [u8]) -> Result<usize, ErrorStack>
pub fn finish(&mut self, out: &mut [u8]) -> Result<usize, ErrorStack>
Finalise the MAC and write into out.
out must be at least self.mac_size() bytes.
Returns the number of bytes written.
§Errors
Sourcepub fn finish_xof(&mut self, out: &mut [u8]) -> Result<(), ErrorStack>
pub fn finish_xof(&mut self, out: &mut [u8]) -> Result<(), ErrorStack>
Finalise with variable-length XOF output (KMAC-128, KMAC-256).
§Errors
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MacCtx
impl RefUnwindSafe for MacCtx
impl !Sync for MacCtx
impl Unpin for MacCtx
impl UnsafeUnpin for MacCtx
impl UnwindSafe for MacCtx
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