2 #include "mbedtls/xtea.h"
6 * depends_on:MBEDTLS_XTEA_C
11 void xtea_encrypt_ecb( data_t * key_str, data_t * src_str,
12 data_t * hex_dst_string )
14 unsigned char output[100];
15 mbedtls_xtea_context ctx;
17 memset(output, 0x00, 100);
20 mbedtls_xtea_setup( &ctx, key_str->x );
21 TEST_ASSERT( mbedtls_xtea_crypt_ecb( &ctx, MBEDTLS_XTEA_ENCRYPT, src_str->x, output ) == 0 );
23 TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
28 void xtea_decrypt_ecb( data_t * key_str, data_t * src_str,
29 data_t * hex_dst_string )
31 unsigned char output[100];
32 mbedtls_xtea_context ctx;
34 memset(output, 0x00, 100);
37 mbedtls_xtea_setup( &ctx, key_str->x );
38 TEST_ASSERT( mbedtls_xtea_crypt_ecb( &ctx, MBEDTLS_XTEA_DECRYPT, src_str->x, output ) == 0 );
40 TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
44 /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */
45 void xtea_encrypt_cbc( data_t * key_str, data_t * iv_str,
46 data_t * src_str, data_t * hex_dst_string )
48 unsigned char output[100];
49 mbedtls_xtea_context ctx;
51 memset(output, 0x00, 100);
54 mbedtls_xtea_setup( &ctx, key_str->x );
55 TEST_ASSERT( mbedtls_xtea_crypt_cbc( &ctx, MBEDTLS_XTEA_ENCRYPT, src_str->len, iv_str->x,
56 src_str->x, output ) == 0 );
58 TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
62 /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */
63 void xtea_decrypt_cbc( data_t * key_str, data_t * iv_str,
64 data_t * src_str, data_t * hex_dst_string )
66 unsigned char output[100];
67 mbedtls_xtea_context ctx;
69 memset(output, 0x00, 100);
72 mbedtls_xtea_setup( &ctx, key_str->x );
73 TEST_ASSERT( mbedtls_xtea_crypt_cbc( &ctx, MBEDTLS_XTEA_DECRYPT, src_str->len, iv_str->x,
74 src_str->x, output ) == 0 );
76 TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
80 /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
83 TEST_ASSERT( mbedtls_xtea_self_test( 1 ) == 0 );