Crate ocb

source ·
Expand description

§RustCrypto: OCB

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

Pure Rust implementation of OCB (RFC 7253)Authenticated Encryption with Associated Data (AEAD) cipher.

Documentation

§Example

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

type Aes128ocb = Ocb3<Aes128, U12>;

let key = Aes128::generate_key(&mut OsRng);
let cipher = Aes128ocb::new(&key);
let nonce = Aes128ocb::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§

Modules§

  • Constants used, reexported for convenience.

Structs§

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

Constants§

Traits§

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

Type Aliases§