#aead #encryption #ocb

no-std ocb3

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

3 releases (breaking)

Uses new Rust 2024

0.2.0-rc.2 Nov 5, 2025
0.1.0 Mar 27, 2024
0.0.0 May 5, 2021

#2798 in Cryptography

Download history 14645/week @ 2025-08-18 14799/week @ 2025-08-25 14766/week @ 2025-09-01 15198/week @ 2025-09-08 13182/week @ 2025-09-15 16053/week @ 2025-09-22 16131/week @ 2025-09-29 15129/week @ 2025-10-06 14410/week @ 2025-10-13 14053/week @ 2025-10-20 15186/week @ 2025-10-27 14510/week @ 2025-11-03 19207/week @ 2025-11-10 18578/week @ 2025-11-17 17628/week @ 2025-11-24 17493/week @ 2025-12-01

74,115 downloads per month
Used in 80 crates (5 directly)

Apache-2.0 OR MIT

33KB
538 lines

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, array::Array},
    consts::U12,
    Ocb3,
};

type Aes128Ocb3 = Ocb3<Aes128, U12>;

let key = Aes128::generate_key().expect("key generation failure");
let cipher = Aes128Ocb3::new(&key);
let nonce = Aes128Ocb3::generate_nonce().expect("nonce failure");
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.

Dependencies

~0.7–1MB
~24K SLoC