X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fsec%2Fcipher%2Faes_test.c;h=1d10740cb083b82c0074b1f07a9f33dcdf86042f;hb=e655a1568f4499a683026a6ba7b95ddb05e60741;hp=8ffb283aa7fa54ad92ecf74cdd227c4a94c56305;hpb=9576112627e2ebe86078648f296445a570c5aa77;p=bertos.git 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; }