mbedtls/tests/suites/test_suite_mdx.function

66 lines
1.5 KiB
Plaintext
Raw Normal View History

BEGIN_HEADER
#include <polarssl/md2.h>
#include <polarssl/md4.h>
#include <polarssl/md5.h>
END_HEADER
BEGIN_CASE
md2_text:text_src_string:hex_hash_string
{
unsigned char src_str[1000];
unsigned char hash_str[1000];
unsigned char output[33];
memset(src_str, 0x00, 1000);
memset(hash_str, 0x00, 1000);
memset(output, 0x00, 33);
strcpy( (char *) src_str, {text_src_string} );
md2( src_str, strlen( (char *) src_str ), output );
hexify( hash_str, output, 16 );
TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 );
}
END_CASE
BEGIN_CASE
md4_text:text_src_string:hex_hash_string
{
unsigned char src_str[1000];
unsigned char hash_str[1000];
unsigned char output[33];
memset(src_str, 0x00, 1000);
memset(hash_str, 0x00, 1000);
memset(output, 0x00, 33);
strcpy( (char *) src_str, {text_src_string} );
md4( src_str, strlen( (char *) src_str ), output );
hexify( hash_str, output, 16 );
TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 );
}
END_CASE
BEGIN_CASE
md5_text:text_src_string:hex_hash_string
{
unsigned char src_str[1000];
unsigned char hash_str[1000];
unsigned char output[33];
memset(src_str, 0x00, 1000);
memset(hash_str, 0x00, 1000);
memset(output, 0x00, 33);
strcpy( (char *) src_str, {text_src_string} );
md5( src_str, strlen( (char *) src_str ), output );
hexify( hash_str, output, 16 );
TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 );
}
END_CASE