Crate xaes_256_gcm

Crate xaes_256_gcm 

Source
Expand description

§RustCrypto: XAES-256-GCM

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

Pure Rust implementation of the XAES-256-GCM extended-nonce Authenticated Encryption with Associated Data (AEAD).

Documentation

§Security Notes

This crate has NOT received any security audit.

Although encryption and decryption passes the test vector, there is no guarantee of constant-time operation.

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.

§Usage

Simple usage (allocating, no associated data):

use xaes_256_gcm::{
    Xaes256Gcm, Nonce, Key,
    aead::{Aead, AeadCore, KeyInit},
};

let key = Xaes256Gcm::generate_key().expect("generate key");
let cipher = Xaes256Gcm::new(&key);
let nonce = Xaes256Gcm::generate_nonce().expect("Generate nonce"); // 192-bits
let ciphertext = cipher.encrypt(&nonce, b"plaintext message".as_ref())?;
let plaintext = cipher.decrypt(&nonce, ciphertext.as_ref())?;
assert_eq!(&plaintext, b"plaintext message");

Re-exports§

pub use aead;
pub use aes;
pub use aes_gcm;

Structs§

Xaes256Gcm
XAES-256-GCM

Constants§

A_MAX
Maximum length of associated data.
C_MAX
Maximum length of ciphertext.
P_MAX
Maximum length of plaintext.

Type Aliases§

Key
XAES-256-GCM key.
Nonce
XAES-256-GCM nonce.
Tag
XAES-256-GCM tag.