Struct botan::MsgAuthCode[][src]

pub struct MsgAuthCode { /* fields omitted */ }

Message authentication code

Methods

impl 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();

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)");

Return information about the key lengths supported by this object

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);

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();

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();

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();

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]

Formats the value using the given formatter. Read more

impl Drop for MsgAuthCode
[src]

Executes the destructor for this type. Read more

Auto Trait Implementations

impl !Send for MsgAuthCode

impl !Sync for MsgAuthCode