libaes 0.4.0

AES cipher in safe Rust
Documentation

libaes

Build Cargo

This is a re-implementation of AES in safe Rust, with zero dependencies. The core algorithm is ported from AES core in OpenSSL 1.1.1 stable. This library strives to be:

  • Correct (as the original OpenSSL implementation)
  • Fast (as OpenSSL 1.1.1)
  • Safe Rust code only.
  • Small: no dependencies.

Currently, this library supports 128-bit, 192-bit and 256-bit keys with CBC mode and CFB128 mode.

Examples

use libaes::Cipher;

let my_key = b"This is the key!"; // key is 128-bit (16 bytes)
let plaintext = b"A plaintext";
let iv = b"This is 16 bytes";

// Create a new cipher
let cipher = Cipher::new_128(my_key);

// Encryption
let encrypted = cipher.cbc_encrypt(iv, plaintext);

// Decryption
let decrypted = cipher.cbc_decrypt(iv, &encrypted[..]);

Correctness

We use the test data in NIST Special Publication 800-38A to verify the cipher, see the test code.

License

Licensed under either of

at your option.

Contribution

Contributions are welcome! Please open an issue in GitHub if any questions.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the above license(s), shall be dual licensed as above, without any additional terms or conditions.