pub struct MsgAuthCode { /* fields omitted */ }
Message authentication code
Create a new message authentication code
let hmac = botan::MsgAuthCode::new("HMAC(SHA-256)").unwrap();
let poly1305 = botan::MsgAuthCode::new("Poly1305").unwrap();
Return the name of this algorithm which may or may not exactly
match what was provided to new()
let mac = botan::MsgAuthCode::new("HMAC(SHA-384)").unwrap();
assert_eq!(mac.algo_name().unwrap(), "HMAC(SHA-384)");
Return information about the key lengths supported by this object
Return the output length of the authentication code, in bytes
let hmac = botan::MsgAuthCode::new("HMAC(SHA-256)").unwrap();
assert_eq!(hmac.output_length().unwrap(), 32);
Set the key for the authentication code object
let hmac = botan::MsgAuthCode::new("HMAC(SHA-256)").unwrap();
hmac.set_key(&vec![0; 16]).unwrap();
Add data to a MAC computation, may be called many times
let hmac = botan::MsgAuthCode::new("HMAC(SHA-256)").unwrap();
assert!(hmac.update(&[23]).is_err());
hmac.set_key(&vec![0; 16]).unwrap();
hmac.update(&[1,2,3]).unwrap();
hmac.update(&[4,5,6]).unwrap();
Complete a MAC computation, after which the object is reset to
MAC a new message with the same key.
let hmac = botan::MsgAuthCode::new("HMAC(SHA-256)").unwrap();
assert!(hmac.update(&[23]).is_err());
hmac.set_key(&vec![0; 16]).unwrap();
hmac.update(&[1,2,3]).unwrap();
hmac.update(&[4,5,6]).unwrap();
let mac = hmac.finish().unwrap();
Clear the MAC key
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());
Formats the value using the given formatter. Read more
Executes the destructor for this type. Read more