Paul Bakker | f725a88 | 2009-07-08 06:43:10 +0000 | [diff] [blame] | 1 | BEGIN_HEADER |
| 2 | #include <polarssl/xtea.h> |
| 3 | END_HEADER |
| 4 | |
Paul Bakker | 5690efc | 2011-05-26 13:16:06 +0000 | [diff] [blame] | 5 | BEGIN_DEPENDENCIES |
| 6 | depends_on:POLARSSL_XTEA_C |
| 7 | END_DEPENDENCIES |
| 8 | |
Paul Bakker | f725a88 | 2009-07-08 06:43:10 +0000 | [diff] [blame] | 9 | BEGIN_CASE |
| 10 | xtea_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 Bakker | f3ccc68 | 2010-03-18 21:21:02 +0000 | [diff] [blame] | 27 | TEST_ASSERT( xtea_crypt_ecb( &ctx, XTEA_ENCRYPT, src_str, output ) == 0 ); |
Paul Bakker | f725a88 | 2009-07-08 06:43:10 +0000 | [diff] [blame] | 28 | hexify( dst_str, output, 8 ); |
| 29 | |
| 30 | TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 ); |
| 31 | } |
| 32 | END_CASE |
| 33 | |
| 34 | BEGIN_CASE |
| 35 | xtea_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 Bakker | f3ccc68 | 2010-03-18 21:21:02 +0000 | [diff] [blame] | 52 | TEST_ASSERT( xtea_crypt_ecb( &ctx, XTEA_DECRYPT, src_str, output ) == 0 ); |
Paul Bakker | f725a88 | 2009-07-08 06:43:10 +0000 | [diff] [blame] | 53 | hexify( dst_str, output, 8 ); |
| 54 | |
| 55 | TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 ); |
| 56 | } |
| 57 | END_CASE |
| 58 | |
| 59 | BEGIN_CASE |
| 60 | xtea_selftest: |
| 61 | { |
| 62 | TEST_ASSERT( xtea_self_test( 0 ) == 0 ); |
| 63 | } |
| 64 | END_CASE |