Expand description
§RustCrypto: OCB3
Pure Rust implementation of the Offset Codebook Mode v3 (OCB3) Authenticated Encryption with Associated Data (AEAD) cipher as described in RFC7253.
§Example
use aes::Aes128;
use ocb3::{
aead::{Aead, AeadCore, Generate, Key, KeyInit, array::Array},
consts::U12,
Ocb3, Nonce
};
type Aes128Ocb3 = Ocb3<Aes128, U12>;
let key = Key::<Aes128>::generate();
let cipher = Aes128Ocb3::new(&key);
let nonce = Nonce::generate(); // MUST be unique per message
let ciphertext = cipher.encrypt(&nonce, b"plaintext message".as_ref()).unwrap();
let plaintext = cipher.decrypt(&nonce, ciphertext.as_ref()).unwrap();
assert_eq!(&plaintext, b"plaintext message");§Security Notes
No security audits of this crate have ever been performed, and it has not been thoroughly assessed to ensure its operation is constant-time on common CPU architectures.
USE AT YOUR OWN RISK!
§License
Licensed under either of:
at your option.
§Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Re-exports§
pub use aead;
Modules§
- consts
- Constants used, reexported for convenience.
Structs§
- Array
Arrayis a newtype for an inner[T; N]array whereNis determined by a genericArraySizeparameter, which is a marker trait for a numeric value determined by ZSTs that impl thetypenum::Unsignedtrait.- Error
- Error type.
- Ocb3
- OCB3: generic over a block cipher implementation, nonce size, and tag size.
Traits§
- Aead
Core - Authenticated Encryption with Associated Data (AEAD) algorithm.
- Aead
InOut - In-place and inout AEAD trait which handles the authentication tag as a return value/separate parameter.
- AsArray
Ref - Obtain an
&Arrayreference for a given type. - Assoc
Array Size - Associates an
ArraySizewith a given type. Can be used to accept[T; N]const generic arguments and convert toArrayinternally. - KeyInit
- Types which can be initialized from a key.
- KeySize
User - Types which use key for initialization.