Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 1 | BEGIN_HEADER |
| 2 | #include <polarssl/arc4.h> |
| 3 | END_HEADER |
| 4 | |
| 5 | BEGIN_CASE |
| 6 | arc4_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]; |
| 11 | |
| 12 | memset(src_str, 0x00, 1000); |
| 13 | memset(key_str, 0x00, 1000); |
| 14 | memset(dst_str, 0x00, 2000); |
| 15 | |
| 16 | int src_len = unhexify( src_str, {hex_src_string} ); |
| 17 | int key_len = unhexify( key_str, {hex_key_string} ); |
| 18 | |
| 19 | arc4_context ctx; |
| 20 | arc4_setup(&ctx, key_str, key_len); |
| 21 | arc4_crypt(&ctx, src_str, src_len); |
| 22 | hexify( dst_str, src_str, src_len ); |
| 23 | |
| 24 | TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 ); |
| 25 | } |
| 26 | END_CASE |
Paul Bakker | 3d36082 | 2009-07-05 11:29:38 +0000 | [diff] [blame] | 27 | |
| 28 | BEGIN_CASE |
| 29 | arc4_selftest: |
| 30 | { |
| 31 | TEST_ASSERT( arc4_self_test( 0 ) == 0 ); |
| 32 | } |
| 33 | END_CASE |