00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "vsl_util.h"
00016 #include "vfer_tests.h"
00017
00018
00019
00020
00021 int main (int argc, char** argv) {
00022
00023 unsigned char plaintext[] = "This is the plaintext.";
00024 unsigned char key[] = "123456789012345";
00025
00026 TEST_INIT("VSL_TEST_AES", "vsl_test_aes.c", stdout, stdout);
00027
00028
00029 uint64_t msgnr = htonll(42);
00030 unsigned char ctr[16];
00031 memset((void*) ctr, 0, 16);
00032 memcpy((void*) ctr, (void*) &msgnr, 8);
00033 unsigned char buf[sizeof(plaintext)];
00034 memcpy((void*) buf, (void*) &plaintext, sizeof(plaintext));
00035 aes_ctr(ctr, key, buf, sizeof(plaintext));
00036
00037
00038 memset((void*) ctr, 0, 16);
00039 memcpy((void*) ctr, (void*) &msgnr, 8);
00040 aes_ctr(ctr, key, buf, sizeof(plaintext));
00041
00042 TEST_CHECK( (memcmp( (void*) &buf, (void*) &plaintext, sizeof(plaintext)) == 0),
00043 "decrypted text doesn't agree with plaintext.");
00044
00045 TEST_SUMMARY();
00046 }
00047
00048
00049
00050
00051
00052
00053
00054