mbedtls/tests/suites/test_suite_mdx.function
Manuel Pégourié-Gonnard 2cf5a7c98e The Great Renaming
A simple execution of tmp/invoke-rename.pl
2015-04-08 13:25:31 +02:00

178 lines
4.9 KiB
Text

/* BEGIN_HEADER */
#include "mbedtls/md2.h"
#include "mbedtls/md4.h"
#include "mbedtls/md5.h"
#include "mbedtls/ripemd160.h"
/* END_HEADER */
/* BEGIN_CASE depends_on:MBEDTLS_MD2_C */
void md2_text( char *text_src_string, char *hex_hash_string )
{
unsigned char src_str[100];
unsigned char hash_str[33];
unsigned char output[16];
memset( src_str, 0x00, sizeof src_str );
memset( hash_str, 0x00, sizeof hash_str );
memset( output, 0x00, sizeof output );
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
mbedtls_md2( src_str, strlen( (char *) src_str ), output );
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_MD4_C */
void md4_text( char *text_src_string, char *hex_hash_string )
{
unsigned char src_str[100];
unsigned char hash_str[33];
unsigned char output[16];
memset( src_str, 0x00, sizeof src_str );
memset( hash_str, 0x00, sizeof hash_str );
memset( output, 0x00, sizeof output );
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
mbedtls_md4( src_str, strlen( (char *) src_str ), output );
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_MD5_C */
void md5_text( char *text_src_string, char *hex_hash_string )
{
unsigned char src_str[100];
unsigned char hash_str[33];
unsigned char output[16];
memset( src_str, 0x00, sizeof src_str );
memset( hash_str, 0x00, sizeof hash_str );
memset( output, 0x00, sizeof output );
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
mbedtls_md5( src_str, strlen( (char *) src_str ), output );
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_RIPEMD160_C */
void ripemd160_text( char *text_src_string, char *hex_hash_string )
{
unsigned char src_str[100];
unsigned char hash_str[41];
unsigned char output[20];
memset(src_str, 0x00, sizeof src_str);
memset(hash_str, 0x00, sizeof hash_str);
memset(output, 0x00, sizeof output);
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
mbedtls_ripemd160( src_str, strlen( (char *) src_str ), output );
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_MD2_C:MBEDTLS_FS_IO */
void mbedtls_md2_file( char *filename, char *hex_hash_string )
{
unsigned char hash_str[33];
unsigned char output[16];
memset( hash_str, 0x00, sizeof hash_str );
memset( output, 0x00, sizeof output );
mbedtls_md2_file( filename, output);
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_MD4_C:MBEDTLS_FS_IO */
void mbedtls_md4_file( char *filename, char *hex_hash_string )
{
unsigned char hash_str[33];
unsigned char output[16];
memset( hash_str, 0x00, sizeof hash_str );
memset( output, 0x00, sizeof output );
mbedtls_md4_file( filename, output);
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_MD5_C:MBEDTLS_FS_IO */
void mbedtls_md5_file( char *filename, char *hex_hash_string )
{
unsigned char hash_str[33];
unsigned char output[16];
memset( hash_str, 0x00, sizeof hash_str );
memset( output, 0x00, sizeof output );
mbedtls_md5_file( filename, output);
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_RIPEMD160_C:MBEDTLS_FS_IO */
void mbedtls_ripemd160_file( char *filename, char *hex_hash_string )
{
unsigned char hash_str[41];
unsigned char output[20];
memset(hash_str, 0x00, sizeof hash_str );
memset(output, 0x00, sizeof output );
mbedtls_ripemd160_file( filename, output);
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_MD2_C:MBEDTLS_SELF_TEST */
void md2_selftest()
{
TEST_ASSERT( mbedtls_md2_self_test( 0 ) == 0 );
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_MD4_C:MBEDTLS_SELF_TEST */
void md4_selftest()
{
TEST_ASSERT( mbedtls_md4_self_test( 0 ) == 0 );
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_MD5_C:MBEDTLS_SELF_TEST */
void md5_selftest()
{
TEST_ASSERT( mbedtls_md5_self_test( 0 ) == 0 );
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_RIPEMD160_C:MBEDTLS_SELF_TEST */
void ripemd160_selftest()
{
TEST_ASSERT( mbedtls_ripemd160_self_test( 0 ) == 0 );
}
/* END_CASE */