1/* BEGIN_HEADER */ 2#include "mbedtls/arc4.h" 3/* END_HEADER */ 4 5/* BEGIN_DEPENDENCIES 6 * depends_on:MBEDTLS_ARC4_C 7 * END_DEPENDENCIES 8 */ 9 10/* BEGIN_CASE */ 11void mbedtls_arc4_crypt( char *hex_src_string, char *hex_key_string, 12 char *hex_dst_string ) 13{ 14 unsigned char src_str[1000]; 15 unsigned char key_str[1000]; 16 unsigned char dst_str[1000]; 17 unsigned char dst_hexstr[2000]; 18 int src_len, key_len; 19 mbedtls_arc4_context ctx; 20 21 memset(src_str, 0x00, 1000); 22 memset(key_str, 0x00, 1000); 23 memset(dst_str, 0x00, 1000); 24 memset(dst_hexstr, 0x00, 2000); 25 mbedtls_arc4_init( &ctx ); 26 27 src_len = unhexify( src_str, hex_src_string ); 28 key_len = unhexify( key_str, hex_key_string ); 29 30 mbedtls_arc4_setup(&ctx, key_str, key_len); 31 TEST_ASSERT( mbedtls_arc4_crypt(&ctx, src_len, src_str, dst_str ) == 0 ); 32 hexify( dst_hexstr, dst_str, src_len ); 33 34 TEST_ASSERT( strcmp( (char *) dst_hexstr, hex_dst_string ) == 0 ); 35 36exit: 37 mbedtls_arc4_free( &ctx ); 38} 39/* END_CASE */ 40 41/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ 42void arc4_selftest() 43{ 44 TEST_ASSERT( mbedtls_arc4_self_test( 1 ) == 0 ); 45} 46/* END_CASE */ 47