blob: e0ad026c4ec7e09cad8b794d41497147a5fbbfb6 [file] [log] [blame]
Paul Bakkerf725a882009-07-08 06:43:10 +00001BEGIN_HEADER
2#include <polarssl/xtea.h>
3END_HEADER
4
Paul Bakker5690efc2011-05-26 13:16:06 +00005BEGIN_DEPENDENCIES
6depends_on:POLARSSL_XTEA_C
7END_DEPENDENCIES
8
Paul Bakkerf725a882009-07-08 06:43:10 +00009BEGIN_CASE
10xtea_encrypt_ecb:hex_key_string:hex_src_string:hex_dst_string
11{
12 unsigned char key_str[100];
13 unsigned char src_str[100];
14 unsigned char dst_str[100];
15 unsigned char output[100];
16 xtea_context ctx;
17
18 memset(key_str, 0x00, 100);
19 memset(src_str, 0x00, 100);
20 memset(dst_str, 0x00, 100);
21 memset(output, 0x00, 100);
22
23 unhexify( key_str, {hex_key_string} );
24 unhexify( src_str, {hex_src_string} );
25
26 xtea_setup( &ctx, key_str );
Paul Bakkerf3ccc682010-03-18 21:21:02 +000027 TEST_ASSERT( xtea_crypt_ecb( &ctx, XTEA_ENCRYPT, src_str, output ) == 0 );
Paul Bakkerf725a882009-07-08 06:43:10 +000028 hexify( dst_str, output, 8 );
29
30 TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 );
31}
32END_CASE
33
34BEGIN_CASE
35xtea_decrypt_ecb:hex_key_string:hex_src_string:hex_dst_string
36{
37 unsigned char key_str[100];
38 unsigned char src_str[100];
39 unsigned char dst_str[100];
40 unsigned char output[100];
41 xtea_context ctx;
42
43 memset(key_str, 0x00, 100);
44 memset(src_str, 0x00, 100);
45 memset(dst_str, 0x00, 100);
46 memset(output, 0x00, 100);
47
48 unhexify( key_str, {hex_key_string} );
49 unhexify( src_str, {hex_src_string} );
50
51 xtea_setup( &ctx, key_str );
Paul Bakkerf3ccc682010-03-18 21:21:02 +000052 TEST_ASSERT( xtea_crypt_ecb( &ctx, XTEA_DECRYPT, src_str, output ) == 0 );
Paul Bakkerf725a882009-07-08 06:43:10 +000053 hexify( dst_str, output, 8 );
54
55 TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 );
56}
57END_CASE
58
59BEGIN_CASE
60xtea_selftest:
61{
62 TEST_ASSERT( xtea_self_test( 0 ) == 0 );
63}
64END_CASE