Crate pmac [−] [src]
Generic implementation of Parallelizable Message Authentication Code (PMAC), otherwise known as OMAC1.
Usage
We will use AES-128 block cipher from aesni crate.
To get the authentication code:
extern crate pmac; extern crate aesni; use aesni::Aes128; use pmac::{Pmac, Mac}; // Create `Mac` trait implementation, namely PMAC-AES128 let mut mac = Pmac::<Aes128>::new_varkey(b"very secret key.").unwrap(); mac.input(b"input message"); // `result` has type `MacResult` which is a thin wrapper around array of // bytes for providing constant time equality check let result = mac.result(); // To get underlying array use `code` method, but be carefull, since // incorrect use of the code value may permit timing attacks which defeat // the security provided by the `MacResult` let code_bytes = result.code();
To verify the message:
let mut mac = Pmac::<Aes128>::new_varkey(b"very secret key.").unwrap(); mac.input(b"input message"); // `verify` will return `Ok(())` if code is correct, `Err(MacError)` otherwise mac.verify(&code_bytes).unwrap();
Reexports
pub extern crate crypto_mac; |
Structs
Pmac |
Generic PMAC instance |
Traits
Mac |
The |