test_suite_arc4.function 866 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* BEGIN_HEADER */
  2. #include "mbedtls/arc4.h"
  3. /* END_HEADER */
  4. /* BEGIN_DEPENDENCIES
  5. * depends_on:MBEDTLS_ARC4_C
  6. * END_DEPENDENCIES
  7. */
  8. /* BEGIN_CASE */
  9. void mbedtls_arc4_crypt( data_t * src_str, data_t * key_str, data_t * dst )
  10. {
  11. unsigned char dst_str[1000];
  12. mbedtls_arc4_context ctx;
  13. memset(dst_str, 0x00, 1000);
  14. mbedtls_arc4_init( &ctx );
  15. mbedtls_arc4_setup(&ctx, key_str->x, key_str->len);
  16. TEST_ASSERT( mbedtls_arc4_crypt(&ctx, src_str->len,
  17. src_str->x, dst_str ) == 0 );
  18. TEST_ASSERT( mbedtls_test_hexcmp( dst_str, dst->x,
  19. src_str->len, dst->len ) == 0 );
  20. exit:
  21. mbedtls_arc4_free( &ctx );
  22. }
  23. /* END_CASE */
  24. /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
  25. void arc4_selftest( )
  26. {
  27. TEST_ASSERT( mbedtls_arc4_self_test( 1 ) == 0 );
  28. }
  29. /* END_CASE */