/AES

This is Rust implementation for Advanced Encryption Standard

Primary LanguageRust

Advanced Encryption Standard

This is would be Rust implementation for AES based on FIBS 197 with three different key sizes, namely: 128 bits, 192 bits, and 256 bits.

The AES algorithm is pretty much state machine with 128 bits/16 bytes state despite the key size, hence the data should be padded to be a multiple of 16 bytes. The recommended padding algorithm is PKCS#7 according to RFC 2315. We are going to have it here.

Using block ciphers such as AES in a naive way is dangerous and can lead to data breaches and malicious tampering with the data. That is why people of encryption needed to devise ways to use block ciphers, hence the need for different modes of operations.

The supported modes of operations in these repository are:

  • Electronic Codebook Mode (ECB)
  • Cipher Block Chaining Mode (CBC)
  • Output Feedback Mode (OFB)
  • Cipher Feedback Mode (CFB)
  • Counter Mode (CTR)
  • Galois Counter Mode (GCM)



Many of these modes are obsolete but I am would be including them for the sake of completeness. This is not a table-based implementation like what you could find at OpenSSL from here, so this can't be used in a very serious application.

How to run

You will need to install Rust on your machine and set up cargo properly in your machine.

Luckily Rust has the easiest and most friendly installation in the world thanks to rustup. You need to visit rustup official website from here and just copy one command in your terminal/cmd and follow the prompt

You will find examples for testing aes internals in /tests/aes_internals.rs and for testing GF8 operations in /tests/gm8_operations.rs and you can run them with

cargo test

and for runnable example you can check /src/main.rs which can be ran with

cargo run