10 // Byte and Byte Array types
11 typedef unsigned char byte;
12 typedef std::vector<byte> byteArray;
14 // Word and Word Array types
15 typedef unsigned int word;
16 typedef std::vector<word> wordArray;
19 class incorrectKeySizeException { };
20 class incorrectTextSizeException { };
21 class badStateArrayException { };
26 AES (const byteArray& key);
28 byteArray encrypt (const byteArray& plaintext) const;
29 byteArray decrypt (const byteArray& ciphertext) const;
32 /* Block size in words -- Always constant in AES.
34 * We also might as well make this static and share it between
35 * all instances of AES. */
36 static const unsigned int Nb = 4;
38 /* Key size in words -- can be 4, 6, or 8.
40 * Once it is set by the constructor, it will never change */
41 const unsigned int Nk;
43 /* Number of rounds -- depends on key size.
45 * Once it is set by the constructor, it will never change */
46 const unsigned int Nr;
48 wordArray keySchedule;
50 void KeyExpansion (const byteArray& key, wordArray& w) const;
51 word SubWord (const word& input) const;
52 word RotWord (const word& input) const;
53 wordArray GetRoundKey (const int round) const;
55 void SubBytes (byteArray& state) const;
56 void ShiftRows (byteArray& state) const;
57 void MixColumns (byteArray& state) const;
58 void AddRoundKey (byteArray& state, const wordArray& w) const;
60 void InvSubBytes (byteArray& state) const;
61 void InvShiftRows (byteArray& state) const;
62 void InvMixColumns (byteArray& state) const;
68 /* vim: set ts=4 sts=4 sw=4 noet tw=112: */