[][src]Crate libaes

A safe and small Rust implementation of AES cipher.

This Rust implementation is ported from the C implementation in OpenSSL 1.1.1 stable with these highlights:

  • Safe Rust code only.
  • Zero dependencies.
  • Fast (as the C version).

In this version, this cipher supports 128-bit keys in CBC mode only.

Examples

use libaes::Cipher;

let my_key = b"This is the key!"; // key is 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[..]);

Structs

Cipher

AES cipher struct

Constants

AES_128_KEY_LEN

128-bit are 16 bytes