#authenticated-encryption #aead #data #mode #security #rfc7253 #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

2 unstable releases

0.1.0 Mar 27, 2024
0.0.0 May 5, 2021

#2622 in Cryptography

Download history 1889/week @ 2024-07-25 2636/week @ 2024-08-01 2308/week @ 2024-08-08 3953/week @ 2024-08-15 4011/week @ 2024-08-22 4211/week @ 2024-08-29 3800/week @ 2024-09-05 4031/week @ 2024-09-12 3582/week @ 2024-09-19 2997/week @ 2024-09-26 4264/week @ 2024-10-03 4536/week @ 2024-10-10 4958/week @ 2024-10-17 5143/week @ 2024-10-24 5860/week @ 2024-10-31 5263/week @ 2024-11-07

22,073 downloads per month
Used in 23 crates (2 directly)

Apache-2.0 OR MIT

29KB
452 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, 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.

Dependencies

~415–720KB
~15K SLoC