Skip to content

Commit

Permalink
add AES test vector (#169)
Browse files Browse the repository at this point in the history
* fix #166

* fix AES bug on ARM, update SSE2NEON header

* revert partial change

* add AES test vector
  • Loading branch information
wangxiao1254 authored Jul 19, 2022
1 parent 4f72aad commit 9e5348c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/aes_opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,33 @@ int main() {
}
}
cout <<"all tests pass!\n";

block key = makeBlock(0x0f0e0d0c0b0a0908, 0x0706050403020100);
block msg = makeBlock(0xffeeddccbbaa9988, 0x7766554433221100);
block res = makeBlock(0x5ac5b47080b7cdd8, 0x30047b6ad8e0c469);//https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.197.pdf page 36
AES_KEY KEY[2];
AES_set_encrypt_key(key, KEY);
AES_ecb_encrypt_blks(&msg, 1, KEY);
if(!cmpBlock(&msg, &res, 1)) {
error("AES test vector fail!");
}

block msg2[2];
msg2[0] = msg2[1] = makeBlock(0xffeeddccbbaa9988, 0x7766554433221100);
AES_set_encrypt_key(key, KEY);
AES_set_encrypt_key(key, KEY+1);
ParaEnc<2, 1>(msg2, KEY);
if(!cmpBlock(msg2, &res, 1) or !cmpBlock(msg2+1, &res, 1)) {
error("AES test vector fail!");
}

msg2[0] = msg2[1] = makeBlock(0xffeeddccbbaa9988, 0x7766554433221100);
ParaEnc<1, 2>(msg2, KEY);
if(!cmpBlock(msg2, &res, 1) or !cmpBlock(msg2+1, &res, 1)) {
error("AES test vector fail!");
}



return 0;
}

0 comments on commit 9e5348c

Please sign in to comment.