blob: 8b133bda8278c9835502851dbb0a5f812acc2b40 [file] [log] [blame]
Paul Bakkerf725a882009-07-08 06:43:10 +00001BEGIN_HEADER
2#include <polarssl/xtea.h>
3END_HEADER
4
5BEGIN_CASE
6xtea_encrypt_ecb:hex_key_string:hex_src_string:hex_dst_string
7{
8 unsigned char key_str[100];
9 unsigned char src_str[100];
10 unsigned char dst_str[100];
11 unsigned char output[100];
12 xtea_context ctx;
13
14 memset(key_str, 0x00, 100);
15 memset(src_str, 0x00, 100);
16 memset(dst_str, 0x00, 100);
17 memset(output, 0x00, 100);
18
19 unhexify( key_str, {hex_key_string} );
20 unhexify( src_str, {hex_src_string} );
21
22 xtea_setup( &ctx, key_str );
Paul Bakkerf3ccc682010-03-18 21:21:02 +000023 TEST_ASSERT( xtea_crypt_ecb( &ctx, XTEA_ENCRYPT, src_str, output ) == 0 );
Paul Bakkerf725a882009-07-08 06:43:10 +000024 hexify( dst_str, output, 8 );
25
26 TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 );
27}
28END_CASE
29
30BEGIN_CASE
31xtea_decrypt_ecb:hex_key_string:hex_src_string:hex_dst_string
32{
33 unsigned char key_str[100];
34 unsigned char src_str[100];
35 unsigned char dst_str[100];
36 unsigned char output[100];
37 xtea_context ctx;
38
39 memset(key_str, 0x00, 100);
40 memset(src_str, 0x00, 100);
41 memset(dst_str, 0x00, 100);
42 memset(output, 0x00, 100);
43
44 unhexify( key_str, {hex_key_string} );
45 unhexify( src_str, {hex_src_string} );
46
47 xtea_setup( &ctx, key_str );
Paul Bakkerf3ccc682010-03-18 21:21:02 +000048 TEST_ASSERT( xtea_crypt_ecb( &ctx, XTEA_DECRYPT, src_str, output ) == 0 );
Paul Bakkerf725a882009-07-08 06:43:10 +000049 hexify( dst_str, output, 8 );
50
51 TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 );
52}
53END_CASE
54
55BEGIN_CASE
56xtea_selftest:
57{
58 TEST_ASSERT( xtea_self_test( 0 ) == 0 );
59}
60END_CASE