{
int i, j;
- std::cout << "Printing: " << name << "\n" << std::endl;
+ std::cout << "\nPrinting: " << name << std::endl;
for (i=0; i<b.size()/16; ++i)
{
int main (int argc, char *argv[])
{
-//#define DEBUG 1
+#define DEBUG 1
//#define MY_TEST2 1
//#define PROBLEM2 1
//#define PROBLEM3 1
+//#define AES_128_EXAMPLE 1
+#define AES_128_EXAMPLE2 1
#if PROBLEM2
int i;
print_by_16s (ciphertext, "Ciphertext");
#endif // MY_TEST2
+#if AES_128_EXAMPLE
+ int i;
+ byteArray key (16, 0);
+ byteArray plaintext (16, 0);
+
+ for (i=0; i<16; ++i)
+ key.at (i) = i;
+
+ for (i=0; i<16; ++i)
+ plaintext.at (i) = (i) | (i<<4);
+
+ AES aes (key);
+ byteArray ciphertext = aes.encrypt (plaintext);
+
+ print_by_16s (key, "Key");
+ print_by_16s (plaintext, "Plaintext");
+ print_by_16s (ciphertext, "Ciphertext");
+#endif // AES_128_EXAMPLE
+
+#if AES_128_EXAMPLE2
+ int i;
+ byteArray key (16, 0);
+ byteArray plaintext (16, 0);
+
+ key[0] = 0x2b;
+ key[1] = 0x7e;
+ key[2] = 0x15;
+ key[3] = 0x16;
+ key[4] = 0x28;
+ key[5] = 0xae;
+ key[6] = 0xd2;
+ key[7] = 0xa6;
+ key[8] = 0xab;
+ key[9] = 0xf7;
+ key[10] = 0x15;
+ key[11] = 0x88;
+ key[12] = 0x09;
+ key[13] = 0xcf;
+ key[14] = 0x4f;
+ key[15] = 0x3c;
+
+ plaintext[0] = 0x32;
+ plaintext[1] = 0x43;
+ plaintext[2] = 0xf6;
+ plaintext[3] = 0xa8;
+ plaintext[4] = 0x88;
+ plaintext[5] = 0x5a;
+ plaintext[6] = 0x30;
+ plaintext[7] = 0x8d;
+ plaintext[8] = 0x31;
+ plaintext[9] = 0x31;
+ plaintext[10] = 0x98;
+ plaintext[11] = 0xa2;
+ plaintext[12] = 0xe0;
+ plaintext[13] = 0x37;
+ plaintext[14] = 0x07;
+ plaintext[15] = 0x34;
+
+ AES aes (key);
+ byteArray ciphertext = aes.encrypt (plaintext);
+
+ print_by_16s (key, "Key");
+ print_by_16s (plaintext, "Plaintext");
+ print_by_16s (ciphertext, "Ciphertext");
+#endif // AES_128_EXAMPLE
return 0;
}