pub struct MacCtx(/* private fields */);
Expand description
A context object used to perform MAC operations.
Implementations§
Source§impl MacCtx
impl MacCtx
Sourcepub fn new(mac: Mac) -> Result<Self, ErrorStack>
pub fn new(mac: Mac) -> Result<Self, ErrorStack>
Creates a new context.
This corresponds to EVP_MAC_CTX_new
.
Sourcepub fn init_ex(
&mut self,
key: Option<&[u8]>,
md: &CStr,
) -> Result<(), ErrorStack>
pub fn init_ex( &mut self, key: Option<&[u8]>, md: &CStr, ) -> Result<(), ErrorStack>
Set key and digest
Sourcepub fn mac_size(&self) -> usize
pub fn mac_size(&self) -> usize
Returns the MAC output size for the given context.
This corresponds to EVP_MAC_CTX_get_mac_size
.
Sourcepub fn block_size(&self) -> usize
pub fn block_size(&self) -> usize
Returns the MAC block size for the given context.
Not all MAC algorithms support this.
This corresponds to EVP_MAC_CTX_get_block_size
.
Sourcepub fn mac_update(&mut self, data: &[u8]) -> Result<(), ErrorStack>
pub fn mac_update(&mut self, data: &[u8]) -> Result<(), ErrorStack>
Add data bytes to the MAC input.
This corresponds to EVP_MAC_update
.
Sourcepub fn mac_final(&mut self, out: Option<&mut [u8]>) -> Result<usize, ErrorStack>
pub fn mac_final(&mut self, out: Option<&mut [u8]>) -> Result<usize, ErrorStack>
Do the final computation and stores the result.
If out
is set to None
, an upper bound on the number of bytes required for the output buffer will be
returned.
This corresponds to EVP_MAC_final
.
Sourcepub fn mac_final_to_vec(
&mut self,
out: &mut Vec<u8>,
) -> Result<usize, ErrorStack>
pub fn mac_final_to_vec( &mut self, out: &mut Vec<u8>, ) -> Result<usize, ErrorStack>
Like Self::mac_final
but appends the result to a Vec
.
Trait Implementations§
Source§impl ForeignType for MacCtx
impl ForeignType for MacCtx
Source§type CType = EVP_MAC_CTX
type CType = EVP_MAC_CTX
The raw C type.
Source§unsafe fn from_ptr(ptr: *mut EVP_MAC_CTX) -> MacCtx
unsafe fn from_ptr(ptr: *mut EVP_MAC_CTX) -> MacCtx
Constructs an instance of this type from its raw type.
Source§fn as_ptr(&self) -> *mut EVP_MAC_CTX
fn as_ptr(&self) -> *mut EVP_MAC_CTX
Returns a raw pointer to the wrapped value.
impl Send for MacCtx
impl Sync for MacCtx
Auto Trait Implementations§
impl Freeze for MacCtx
impl RefUnwindSafe for MacCtx
impl Unpin 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