Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / mbedtls / repo / tests / suites / test_suite_xtea.function
1 /* BEGIN_HEADER */
2 #include "mbedtls/xtea.h"
3 /* END_HEADER */
4
5 /* BEGIN_DEPENDENCIES
6  * depends_on:MBEDTLS_XTEA_C
7  * END_DEPENDENCIES
8  */
9
10 /* BEGIN_CASE */
11 void xtea_encrypt_ecb( data_t * key_str, data_t * src_str,
12                        data_t * hex_dst_string )
13 {
14     unsigned char output[100];
15     mbedtls_xtea_context ctx;
16
17     memset(output, 0x00, 100);
18
19
20     mbedtls_xtea_setup( &ctx, key_str->x );
21     TEST_ASSERT( mbedtls_xtea_crypt_ecb( &ctx, MBEDTLS_XTEA_ENCRYPT, src_str->x, output ) == 0 );
22
23     TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
24 }
25 /* END_CASE */
26
27 /* BEGIN_CASE */
28 void xtea_decrypt_ecb( data_t * key_str, data_t * src_str,
29                        data_t * hex_dst_string )
30 {
31     unsigned char output[100];
32     mbedtls_xtea_context ctx;
33
34     memset(output, 0x00, 100);
35
36
37     mbedtls_xtea_setup( &ctx, key_str->x );
38     TEST_ASSERT( mbedtls_xtea_crypt_ecb( &ctx, MBEDTLS_XTEA_DECRYPT, src_str->x, output ) == 0 );
39
40     TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
41 }
42 /* END_CASE */
43
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 )
47 {
48     unsigned char output[100];
49     mbedtls_xtea_context ctx;
50
51     memset(output, 0x00, 100);
52
53
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 );
57
58     TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
59 }
60 /* END_CASE */
61
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 )
65 {
66     unsigned char output[100];
67     mbedtls_xtea_context ctx;
68
69     memset(output, 0x00, 100);
70
71
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 );
75
76     TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
77 }
78 /* END_CASE */
79
80 /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
81 void xtea_selftest(  )
82 {
83     TEST_ASSERT( mbedtls_xtea_self_test( 1 ) == 0 );
84 }
85 /* END_CASE */