blob: e3ff30376569a355ecffe15c1826afa983bd0957 [file] [log] [blame]
Paul Bakker33b43f12013-08-20 11:48:36 +02001/* BEGIN_HEADER */
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +00002#include "mbedtls/arc4.h"
Paul Bakker33b43f12013-08-20 11:48:36 +02003/* END_HEADER */
Paul Bakker367dae42009-06-28 21:50:27 +00004
Paul Bakker33b43f12013-08-20 11:48:36 +02005/* BEGIN_DEPENDENCIES
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006 * depends_on:MBEDTLS_ARC4_C
Paul Bakker33b43f12013-08-20 11:48:36 +02007 * END_DEPENDENCIES
8 */
Paul Bakker5690efc2011-05-26 13:16:06 +00009
Paul Bakker33b43f12013-08-20 11:48:36 +020010/* BEGIN_CASE */
Azim Khanf1aaec92017-05-30 14:23:15 +010011void mbedtls_arc4_crypt( uint8_t * src_str, uint32_t src_len,
12 uint8_t * key_str, uint32_t key_len,
13 uint8_t * hex_dst_string, uint32_t hex_dst_string_len
14 )
Paul Bakker367dae42009-06-28 21:50:27 +000015{
Paul Bakkerbaad6502010-03-21 15:42:15 +000016 unsigned char dst_str[1000];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020017 mbedtls_arc4_context ctx;
Paul Bakker367dae42009-06-28 21:50:27 +000018
Paul Bakkerbaad6502010-03-21 15:42:15 +000019 memset(dst_str, 0x00, 1000);
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020020 mbedtls_arc4_init( &ctx );
Paul Bakker367dae42009-06-28 21:50:27 +000021
Paul Bakker367dae42009-06-28 21:50:27 +000022
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020023 mbedtls_arc4_setup(&ctx, key_str, key_len);
24 TEST_ASSERT( mbedtls_arc4_crypt(&ctx, src_len, src_str, dst_str ) == 0 );
Paul Bakker367dae42009-06-28 21:50:27 +000025
Azim Khanf1aaec92017-05-30 14:23:15 +010026 TEST_ASSERT( hexcmp( dst_str, hex_dst_string, src_len, hex_dst_string_len ) == 0 );
Paul Bakker8cfd9d82014-06-18 11:16:11 +020027
Paul Bakkerbd51b262014-07-10 15:26:12 +020028exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020029 mbedtls_arc4_free( &ctx );
Paul Bakker367dae42009-06-28 21:50:27 +000030}
Paul Bakker33b43f12013-08-20 11:48:36 +020031/* END_CASE */
Paul Bakker3d360822009-07-05 11:29:38 +000032
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020033/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
Azim Khanf1aaec92017-05-30 14:23:15 +010034void arc4_selftest( )
Paul Bakker3d360822009-07-05 11:29:38 +000035{
Andres AG93012e82016-09-09 09:10:28 +010036 TEST_ASSERT( mbedtls_arc4_self_test( 1 ) == 0 );
Paul Bakker3d360822009-07-05 11:29:38 +000037}
Paul Bakker33b43f12013-08-20 11:48:36 +020038/* END_CASE */