blob: 6c71cb2320ef84b0da1fd1ec72e2fd3b5ebddd63 [file] [log] [blame]
Paul Bakker367dae42009-06-28 21:50:27 +00001BEGIN_HEADER
2#include <polarssl/arc4.h>
3END_HEADER
4
5BEGIN_CASE
6arc4_crypt:hex_src_string:hex_key_string:hex_dst_string
7{
8 unsigned char src_str[1000];
9 unsigned char key_str[1000];
10 unsigned char dst_str[2000];
Paul Bakker69998dd2009-07-11 19:15:20 +000011 int src_len, key_len;
12 arc4_context ctx;
Paul Bakker367dae42009-06-28 21:50:27 +000013
14 memset(src_str, 0x00, 1000);
15 memset(key_str, 0x00, 1000);
16 memset(dst_str, 0x00, 2000);
17
Paul Bakker69998dd2009-07-11 19:15:20 +000018 src_len = unhexify( src_str, {hex_src_string} );
19 key_len = unhexify( key_str, {hex_key_string} );
Paul Bakker367dae42009-06-28 21:50:27 +000020
Paul Bakker367dae42009-06-28 21:50:27 +000021 arc4_setup(&ctx, key_str, key_len);
22 arc4_crypt(&ctx, src_str, src_len);
23 hexify( dst_str, src_str, src_len );
24
25 TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 );
26}
27END_CASE
Paul Bakker3d360822009-07-05 11:29:38 +000028
29BEGIN_CASE
30arc4_selftest:
31{
32 TEST_ASSERT( arc4_self_test( 0 ) == 0 );
33}
34END_CASE