AES Implementation
This may only be used for the Modes lab
The file aes.tar.gz contains a public domain reference implementation of AES. Download it to your account. You can untar it with a command such as: "tar -zxvf aes.tar.gz". You may use it or another implementation of AES, but you (obviously) must write all code for the modes yourself.
AES Library Information:
- How to compile/link the aes library:
- First compile the aes library with: g++ -c aes_core.c
- Make sure to #include "aes.h" in your program.
- Compile your program. For example: g++ -c ecb.cpp
- Link them together with: g++ -o ecb ecb.o aes_core.o
- How to use the aes library:
#include "aes.h"
//declare an AES_KEY struct
AES_KEY myAESkey;
//Before you do any en/decrypting, you need to fill up an AES_KEY struct.
AES_set_encrypt_key((const unsigned char *)myPasswd, 128, &myAESkey);
//Now that your AES_KEY is ready to go, you can now encrypt. To do so:
AES_encrypt((const unsigned char *)myIn, myOut, (const AES_KEY *)&myAESkey);
This will only encrypt 128 bits (16 bytes) of data at a time, so copy 16 bytes into myIn. After the call to AES_encrypt myOut will contain 16 bytes of encrypted data. Make sure to use the corresponding AES_set_decrypt function with AES_decrypt.