Expand description
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.
§Usage
Simple usage (allocating, no associated data):
ⓘ
use aes::Aes256;
use ccm::{
aead::{Aead, KeyInit, OsRng, generic_array::GenericArray},
consts::{U10, U13},
Ccm,
};
// AES-256-CCM type with tag and nonce size equal to 10 and 13 bytes respectively
pub type Aes256Ccm = Ccm<Aes256, U10, U13>;
let key = Aes256Ccm::generate_key(&mut OsRng);
let cipher = Aes256Ccm::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())?;
let plaintext = cipher.decrypt(nonce, ciphertext.as_ref())?;
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
.
Re-exports§
pub use aead;
Modules§
Structs§
Traits§
- Aead
Core - Authenticated Encryption with Associated Data (AEAD) algorithm core trait.
- Aead
InPlace - In-place stateless AEAD trait.
- KeyInit
- Types which can be initialized from key.
- KeySize
User - Types which use key for initialization.
- Nonce
Size - Trait implemented for valid nonce sizes, i.e.
U7
,U8
,U9
,U10
,U11
,U12
, andU13
. - TagSize
- Trait implemented for valid tag sizes, i.e.
U4
,U6
,U8
,U10
,U12
,U14
, andU16
.
Type Aliases§
- Key
- Key used by
KeySizeUser
implementors. - Nonce
- CCM nonces
- Tag
- CCM tags