blob: c1e2386656ad6d80710c6dea00557c7f3032a7f1 [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 */
Ronald Cronaea41df2020-06-26 14:33:03 +020011void mbedtls_arc4_crypt( data_t * src_str, data_t * key_str, data_t * dst )
Paul Bakker367dae42009-06-28 21:50:27 +000012{
Paul Bakkerbaad6502010-03-21 15:42:15 +000013 unsigned char dst_str[1000];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020014 mbedtls_arc4_context ctx;
Paul Bakker367dae42009-06-28 21:50:27 +000015
Paul Bakkerbaad6502010-03-21 15:42:15 +000016 memset(dst_str, 0x00, 1000);
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020017 mbedtls_arc4_init( &ctx );
Paul Bakker367dae42009-06-28 21:50:27 +000018
Paul Bakker367dae42009-06-28 21:50:27 +000019
Azim Khand30ca132017-06-09 04:32:58 +010020 mbedtls_arc4_setup(&ctx, key_str->x, key_str->len);
Ronald Cronaea41df2020-06-26 14:33:03 +020021 TEST_ASSERT( mbedtls_arc4_crypt(&ctx, src_str->len,
22 src_str->x, dst_str ) == 0 );
Paul Bakker367dae42009-06-28 21:50:27 +000023
Ronald Cronaea41df2020-06-26 14:33:03 +020024 TEST_ASSERT( mbedtls_test_hexcmp( dst_str, dst->x,
25 src_str->len, dst->len ) == 0 );
Paul Bakker8cfd9d82014-06-18 11:16:11 +020026
Paul Bakkerbd51b262014-07-10 15:26:12 +020027exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020028 mbedtls_arc4_free( &ctx );
Paul Bakker367dae42009-06-28 21:50:27 +000029}
Paul Bakker33b43f12013-08-20 11:48:36 +020030/* END_CASE */
Paul Bakker3d360822009-07-05 11:29:38 +000031
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020032/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
Azim Khanf1aaec92017-05-30 14:23:15 +010033void arc4_selftest( )
Paul Bakker3d360822009-07-05 11:29:38 +000034{
Andres AG93012e82016-09-09 09:10:28 +010035 TEST_ASSERT( mbedtls_arc4_self_test( 1 ) == 0 );
Paul Bakker3d360822009-07-05 11:29:38 +000036}
Paul Bakker33b43f12013-08-20 11:48:36 +020037/* END_CASE */