From 45f8c1d234da52d83e76bc7a52f1b83bfd7dc6be Mon Sep 17 00:00:00 2001 From: rasky Date: Mon, 4 Oct 2010 18:21:05 +0000 Subject: [PATCH] SEC: add another AES test for debugging purposes git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4398 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/sec/cipher/aes_test.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bertos/sec/cipher/aes_test.c b/bertos/sec/cipher/aes_test.c index 8ffb283a..1d10740c 100644 --- a/bertos/sec/cipher/aes_test.c +++ b/bertos/sec/cipher/aes_test.c @@ -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; } -- 2.25.1