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. */
32 static const unsigned int Nb = 4;
34 /* Key size in words -- can be 4, 6, or 8. */
35 const unsigned int Nk;
37 /* Number of rounds -- depends on key size. */
38 const unsigned int Nr;
40 wordArray keySchedule;
42 void KeyExpansion (const byteArray& key, wordArray& w) const;
43 word SubWord (const word& input) const;
44 word RotWord (const word& input) const;
45 wordArray GetRoundKey (const int round) const;
47 void SubBytes (byteArray& state) const;
48 void ShiftRows (byteArray& state) const;
49 void MixColumns (byteArray& state) const;
50 void AddRoundKey (byteArray& state, const wordArray& w) const;
52 void InvSubBytes (byteArray& state) const;
53 void InvShiftRows (byteArray& state) const;
54 void InvMixColumns (byteArray& state) const;
60 /* vim: set ts=4 sts=4 sw=4 noet tw=112: */