SEC: add another AES test for debugging purposes
authorrasky <rasky@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 4 Oct 2010 18:21:05 +0000 (18:21 +0000)
committerrasky <rasky@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 4 Oct 2010 18:21:05 +0000 (18:21 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4398 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/sec/cipher/aes_test.c

index 8ffb283aa7fa54ad92ecf74cdd227c4a94c56305..1d10740cb083b82c0074b1f07a9f33dcdf86042f 100644 (file)
@@ -1082,6 +1082,15 @@ int AES_testRun(void)
        //BlockCipher *c = AES192_stackinit();
        //cipher_set_key(c, "\x8e\x73\xb0\xf7\xda\x0e\x64\x52\xc8\x10\xf3\x2b\x80\x90\x79\xe5\x62\xf8\xea\xd2\x52\x2c\x6b\x7b");
 
+       // This is the step-by-step example in FIPS-197
+       BlockCipher *c = AES128_stackinit();
+       uint8_t data[] = { "\x32\x43\xf6\xa8\x88\x5a\x30\x8d\x31\x31\x98\xa2\xe0\x37\x07\x34" };
+       cipher_set_key(c, "\x2b\x7e\x15\x16\x28\xae\xd2\xa6\xab\xf7\x15\x88\x09\xcf\x4f\x3c");
+       cipher_ecb_encrypt(c, data);
+       ASSERT(memcmp(data, "\x39\x25\x84\x1D\x02\xDC\x09\xFB\xDC\x11\x85\x97\x19\x6A\x0B\x32", 16) == 0);
+       cipher_ecb_decrypt(c, data);
+       ASSERT(memcmp(data, "\x32\x43\xf6\xa8\x88\x5a\x30\x8d\x31\x31\x98\xa2\xe0\x37\x07\x34", 16) == 0);
+
        return 0;
 }