pub struct HMacCtx(/* private fields */);
Expand description
A context object used to perform MAC operations.
Implementations§
Source§impl HMacCtx
impl HMacCtx
Sourcepub fn new() -> Result<Self, ErrorStack>
pub fn new() -> Result<Self, ErrorStack>
Creates a new context.
This corresponds to HMAC_CTX_new
.
Methods from Deref<Target = HMacCtxRef>§
Sourcepub fn reset(&mut self) -> Result<(), ErrorStack>
pub fn reset(&mut self) -> Result<(), ErrorStack>
Clears an existing HMAC_CTX and associated resources.
This will make it suitable for new computations as if it was newly created with HMAC_CTX_new().
This corresponds to HMAC_CTX_reset
.
Sourcepub fn copy(&mut self, src: &HMacCtxRef) -> Result<(), ErrorStack>
pub fn copy(&mut self, src: &HMacCtxRef) -> Result<(), ErrorStack>
This corresponds to HMAC_CTX_copy
.
Sourcepub fn init_ex(
&mut self,
key: Option<&[u8]>,
md: &MdRef,
) -> Result<(), ErrorStack>
pub fn init_ex( &mut self, key: Option<&[u8]>, md: &MdRef, ) -> Result<(), ErrorStack>
This corresponds to HMAC_Init_ex
.
Sourcepub fn md(&self) -> Option<&MdRef>
pub fn md(&self) -> Option<&MdRef>
This corresponds to HMAC_CTX_get_md
.
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Returns the size, in bytes, of the HMAC that will be produced by ctx.
On entry, ctx must have been setup with init_ex
This corresponds to HMAC_size
.
Sourcepub fn hmac_update(&mut self, data: &[u8]) -> Result<(), ErrorStack>
pub fn hmac_update(&mut self, data: &[u8]) -> Result<(), ErrorStack>
Add data bytes to the MAC input.
This corresponds to HMAC_Update
.
Sourcepub fn hmac_final(&mut self, out: &mut [u8]) -> Result<usize, ErrorStack>
pub fn hmac_final(&mut self, out: &mut [u8]) -> Result<usize, ErrorStack>
Place the message authentication code in out.
This corresponds to HMAC_Update
.
Sourcepub fn hmac_final_to_vec(
&mut self,
out: &mut Vec<u8>,
) -> Result<usize, ErrorStack>
pub fn hmac_final_to_vec( &mut self, out: &mut Vec<u8>, ) -> Result<usize, ErrorStack>
Like Self::hmac_final
but appends the signature to a Vec
.
Trait Implementations§
Source§impl AsRef<HMacCtxRef> for HMacCtx
impl AsRef<HMacCtxRef> for HMacCtx
Source§fn as_ref(&self) -> &HMacCtxRef
fn as_ref(&self) -> &HMacCtxRef
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl Borrow<HMacCtxRef> for HMacCtx
impl Borrow<HMacCtxRef> for HMacCtx
Source§fn borrow(&self) -> &HMacCtxRef
fn borrow(&self) -> &HMacCtxRef
Immutably borrows from an owned value. Read more
Source§impl Deref for HMacCtx
impl Deref for HMacCtx
Source§type Target = HMacCtxRef
type Target = HMacCtxRef
The resulting type after dereferencing.
Source§fn deref(&self) -> &HMacCtxRef
fn deref(&self) -> &HMacCtxRef
Dereferences the value.
Source§impl DerefMut for HMacCtx
impl DerefMut for HMacCtx
Source§fn deref_mut(&mut self) -> &mut HMacCtxRef
fn deref_mut(&mut self) -> &mut HMacCtxRef
Mutably dereferences the value.
Source§impl ForeignType for HMacCtx
impl ForeignType for HMacCtx
impl Send for HMacCtx
impl Sync for HMacCtx
Auto Trait Implementations§
impl Freeze for HMacCtx
impl RefUnwindSafe for HMacCtx
impl Unpin for HMacCtx
impl UnwindSafe for HMacCtx
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