9 // Byte and Byte Array types
10 typedef unsigned char byte;
11 typedef std::vector<byte> byteArray;
13 // Word and Word Array types
14 typedef unsigned int word;
15 typedef std::vector<word> wordArray;
18 class incorrectKeySizeException { };
19 class incorrectTextSizeException { };
20 class badStateArrayException { };
25 AES (const byteArray& key);
27 byteArray encrypt (const byteArray& plaintext) const;
28 byteArray decrypt (const byteArray& ciphertext) const;
31 /* Block size in words -- Always constant in AES.
33 * We also might as well make this static and share it between
34 * all instances of AES. */
35 static const unsigned int Nb = 4;
37 /* Key size in words -- can be 4, 6, or 8.
39 * Once it is set by the constructor, it will never change */
40 const unsigned int Nk;
42 /* Number of rounds -- depends on key size.
44 * Once it is set by the constructor, it will never change */
45 const unsigned int Nr;
47 wordArray keySchedule;
49 void KeyExpansion (const byteArray& key, wordArray& w) const;
50 word SubWord (const word& input) const;
51 word RotWord (const word& input) const;
52 wordArray GetRoundKey (const int round) const;
54 void SubBytes (byteArray& state) const;
55 void ShiftRows (byteArray& state) const;
56 void MixColumns (byteArray& state) const;
57 void AddRoundKey (byteArray& state, const wordArray& w) const;
59 void InvSubBytes (byteArray& state) const;
60 void InvShiftRows (byteArray& state) const;
61 void InvMixColumns (byteArray& state) const;
67 /* vim: set ts=4 sts=4 sw=4 noet tw=112: */