#include #include #include "aes.h" using namespace std; namespace AES{ //http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf void subWord(uint8_t *word); void keyExpand(uint8_t *keysched,const uint8_t *key,int keylen,int numrounds); void addRoundKey(uint8_t *state,const uint8_t *roundkey); void subBytes(uint8_t *state){ subWord(state); subWord(state+4); subWord(state+8); subWord(state+12); } void shiftRows(uint8_t *state); void mixColumns(uint8_t *state); void encryptBlock(uint8_t *state,const uint8_t *key,const uint8_t *data,int keylen,int numrounds){ uint8_t keysched[16*(numrounds+1)]; keyExpand(keysched,key,keylen,numrounds); memcpy(state,data,16); addRoundKey(state,keysched); for(int round=0;round