[][src]Crate ccm

Counter with CBC-MAC (CCM): Authenticated Encryption and Associated Data (AEAD) algorithm generic over block ciphers with block size equal to 128 bits as specified in RFC 3610.


Simple usage (allocating, no associated data):

use ccm::{Ccm, consts::{U10, U13}};
use ccm::aead::{Aead, NewAead, generic_array::GenericArray};
use aes::Aes256;

// AES-CCM type with tag and nonce size equal to 10 and 13 bytes respectively
type AesCcm = Ccm<Aes256, U10, U13>;

let key = GenericArray::from_slice(b"an example very very secret key.");
let cipher = AesCcm::new(key);

let nonce = GenericArray::from_slice(b"unique nonce."); // 13-bytes; unique per message

let ciphertext = cipher.encrypt(nonce, b"plaintext message".as_ref())
    .expect("encryption failure!"); // NOTE: handle this error to avoid panics!

let plaintext = cipher.decrypt(nonce, ciphertext.as_ref())
    .expect("decryption failure!"); // NOTE: handle this error to avoid panics!

assert_eq!(&plaintext, b"plaintext message");

This crate implements traits from the aead crate and is capable to perfrom encryption and decryption in-place wihout relying on alloc.


pub use aead;



Type aliases for many constants.



CCM instance generic over an underlying block cipher.