Struct botan::MsgAuthCode [−][src]
Message authentication code
Implementations
impl MsgAuthCode
[src]
pub fn new(name: &str) -> Result<MsgAuthCode>
[src]
Create a new message authentication code
Examples
let hmac = botan::MsgAuthCode::new("HMAC(SHA-256)").unwrap();
let poly1305 = botan::MsgAuthCode::new("Poly1305").unwrap();
pub fn algo_name(&self) -> Result<String>
[src]
Return the name of this algorithm which may or may not exactly match what was provided to new()
Examples
let mac = botan::MsgAuthCode::new("HMAC(SHA-384)").unwrap(); assert_eq!(mac.algo_name().unwrap(), "HMAC(SHA-384)");
pub fn key_spec(&self) -> Result<KeySpec>
[src]
Return information about the key lengths supported by this object
pub fn output_length(&self) -> Result<usize>
[src]
Return the output length of the authentication code, in bytes
Examples
let hmac = botan::MsgAuthCode::new("HMAC(SHA-256)").unwrap(); assert_eq!(hmac.output_length().unwrap(), 32);
pub fn set_key(&self, key: &[u8]) -> Result<()>
[src]
Set the key for the authentication code object
Examples
let hmac = botan::MsgAuthCode::new("HMAC(SHA-256)").unwrap(); hmac.set_key(&vec![0; 16]).unwrap();
pub fn update(&self, data: &[u8]) -> Result<()>
[src]
Add data to a MAC computation, may be called many times
Examples
let hmac = botan::MsgAuthCode::new("HMAC(SHA-256)").unwrap(); assert!(hmac.update(&[23]).is_err()); // key not set yet hmac.set_key(&vec![0; 16]).unwrap(); hmac.update(&[1,2,3]).unwrap(); hmac.update(&[4,5,6]).unwrap();
pub fn finish(&self) -> Result<Vec<u8>>
[src]
Complete a MAC computation, after which the object is reset to MAC a new message with the same key.
Examples
let hmac = botan::MsgAuthCode::new("HMAC(SHA-256)").unwrap(); assert!(hmac.update(&[23]).is_err()); // key not set yet hmac.set_key(&vec![0; 16]).unwrap(); hmac.update(&[1,2,3]).unwrap(); hmac.update(&[4,5,6]).unwrap(); let mac = hmac.finish().unwrap();
pub fn clear(&self) -> Result<()>
[src]
Clear the MAC key
Examples
let hmac = botan::MsgAuthCode::new("HMAC(SHA-256)").unwrap(); hmac.set_key(&vec![0; 16]).unwrap(); hmac.update(&[1,2,3]).unwrap(); hmac.clear().unwrap(); assert!(hmac.update(&[23]).is_err()); // key not set anymore
Trait Implementations
impl Debug for MsgAuthCode
[src]
impl Drop for MsgAuthCode
[src]
Auto Trait Implementations
impl RefUnwindSafe for MsgAuthCode
impl !Send for MsgAuthCode
impl !Sync for MsgAuthCode
impl Unpin for MsgAuthCode
impl UnwindSafe for MsgAuthCode
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,