blob: edfe5c748e2c40126b7535d4d6f8c6f9b55b6820 [file] [log] [blame]
Paul Bakker367dae42009-06-28 21:50:27 +00001BEGIN_HEADER
2#include <polarssl/arc4.h>
3END_HEADER
4
Paul Bakker5690efc2011-05-26 13:16:06 +00005BEGIN_DEPENDENCIES
6depends_on:POLARSSL_ARC4_C
7END_DEPENDENCIES
8
Paul Bakker367dae42009-06-28 21:50:27 +00009BEGIN_CASE
10arc4_crypt:hex_src_string:hex_key_string:hex_dst_string
11{
12 unsigned char src_str[1000];
13 unsigned char key_str[1000];
Paul Bakkerbaad6502010-03-21 15:42:15 +000014 unsigned char dst_str[1000];
15 unsigned char dst_hexstr[2000];
Paul Bakker69998dd2009-07-11 19:15:20 +000016 int src_len, key_len;
17 arc4_context ctx;
Paul Bakker367dae42009-06-28 21:50:27 +000018
19 memset(src_str, 0x00, 1000);
20 memset(key_str, 0x00, 1000);
Paul Bakkerbaad6502010-03-21 15:42:15 +000021 memset(dst_str, 0x00, 1000);
22 memset(dst_hexstr, 0x00, 2000);
Paul Bakker367dae42009-06-28 21:50:27 +000023
Paul Bakker69998dd2009-07-11 19:15:20 +000024 src_len = unhexify( src_str, {hex_src_string} );
25 key_len = unhexify( key_str, {hex_key_string} );
Paul Bakker367dae42009-06-28 21:50:27 +000026
Paul Bakker367dae42009-06-28 21:50:27 +000027 arc4_setup(&ctx, key_str, key_len);
Paul Bakkerbaad6502010-03-21 15:42:15 +000028 TEST_ASSERT( arc4_crypt(&ctx, src_len, src_str, dst_str ) == 0 );
29 hexify( dst_hexstr, dst_str, src_len );
Paul Bakker367dae42009-06-28 21:50:27 +000030
Paul Bakkerbaad6502010-03-21 15:42:15 +000031 TEST_ASSERT( strcmp( (char *) dst_hexstr, {hex_dst_string} ) == 0 );
Paul Bakker367dae42009-06-28 21:50:27 +000032}
33END_CASE
Paul Bakker3d360822009-07-05 11:29:38 +000034
35BEGIN_CASE
36arc4_selftest:
37{
38 TEST_ASSERT( arc4_self_test( 0 ) == 0 );
39}
40END_CASE