Crate ocb3

Crate ocb3 

Source
Expand description

§RustCrypto: OCB3

crate Docs Apache2/MIT licensed Rust Version Project Chat Build Status

Pure Rust implementation of the Offset Codebook Mode v3 (OCB3) Authenticated Encryption with Associated Data (AEAD) cipher as described in RFC7253.

Documentation

§Example

use aes::Aes128;
use ocb3::{
    aead::{Aead, AeadCore, KeyInit, OsRng, generic_array::GenericArray},
    consts::U12,
    Ocb3,
};

type Aes128Ocb3 = Ocb3<Aes128, U12>;

let key = Aes128::generate_key(&mut OsRng);
let cipher = Aes128Ocb3::new(&key);
let nonce = Aes128Ocb3::generate_nonce(&mut OsRng);
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.
sealed 🔒
util 🔒

Structs§

Error
Error type.
GenericArray
Struct representing a generic array - GenericArray<T, N> works like [T; N]
Ocb3
OCB3: generic over a block cipher implementation, nonce size, and tag size.

Constants§

A_MAX
Max associated data.
C_MAX
Max ciphertext.
L_TABLE_SIZE 🔒
Number of L values to be precomputed. Precomputing m values, allows processing inputs of length up to 2^m blocks (2^m * 16 bytes) without needing to calculate L values at runtime.
P_MAX
Max plaintext.

Traits§

AeadCore
Authenticated Encryption with Associated Data (AEAD) algorithm core trait.
AeadInPlace
In-place stateless AEAD trait.
KeyInit
Types which can be initialized from key.
KeySizeUser
Types which use key for initialization.

Functions§

initial_offset 🔒
Computes the initial offset as defined in https://www.rfc-editor.org/rfc/rfc7253.html#section-4.2
key_dependent_variables 🔒
Computes key-dependent variables defined in https://www.rfc-editor.org/rfc/rfc7253.html#section-4.1
nonce_dependent_variables 🔒
Computes nonce-dependent variables as defined in https://www.rfc-editor.org/rfc/rfc7253.html#section-4.2

Type Aliases§

Nonce
OCB3 nonce
Sum 🔒
SumSize 🔒
Output of the HASH function defined in https://www.rfc-editor.org/rfc/rfc7253.html#section-4.1
Tag
OCB3 tag