2013-08-20 09:48:36 +00:00
|
|
|
/* BEGIN_HEADER */
|
2015-03-09 17:05:11 +00:00
|
|
|
#include "mbedtls/md2.h"
|
|
|
|
#include "mbedtls/md4.h"
|
|
|
|
#include "mbedtls/md5.h"
|
|
|
|
#include "mbedtls/ripemd160.h"
|
2013-08-20 09:48:36 +00:00
|
|
|
/* END_HEADER */
|
2009-06-28 21:50:27 +00:00
|
|
|
|
2015-04-08 10:49:31 +00:00
|
|
|
/* BEGIN_CASE depends_on:MBEDTLS_MD2_C */
|
2013-08-20 09:48:36 +00:00
|
|
|
void md2_text( char *text_src_string, char *hex_hash_string )
|
2009-06-28 21:50:27 +00:00
|
|
|
{
|
2017-06-28 09:51:17 +00:00
|
|
|
int ret;
|
2014-01-17 13:23:48 +00:00
|
|
|
unsigned char src_str[100];
|
|
|
|
unsigned char hash_str[33];
|
|
|
|
unsigned char output[16];
|
2009-06-28 21:50:27 +00:00
|
|
|
|
2014-01-17 13:23:48 +00:00
|
|
|
memset( src_str, 0x00, sizeof src_str );
|
|
|
|
memset( hash_str, 0x00, sizeof hash_str );
|
|
|
|
memset( output, 0x00, sizeof output );
|
2009-06-28 21:50:27 +00:00
|
|
|
|
2014-04-17 14:06:37 +00:00
|
|
|
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
|
2009-06-28 21:50:27 +00:00
|
|
|
|
2017-06-28 09:51:17 +00:00
|
|
|
ret = mbedtls_md2_ext( src_str, strlen( (char *) src_str ), output );
|
|
|
|
TEST_ASSERT( ret == 0 ) ;
|
2014-01-17 13:23:48 +00:00
|
|
|
hexify( hash_str, output, sizeof output );
|
2009-06-28 21:50:27 +00:00
|
|
|
|
2013-08-20 09:48:36 +00:00
|
|
|
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
2009-06-28 21:50:27 +00:00
|
|
|
}
|
2013-08-20 09:48:36 +00:00
|
|
|
/* END_CASE */
|
2009-06-28 21:50:27 +00:00
|
|
|
|
2015-04-08 10:49:31 +00:00
|
|
|
/* BEGIN_CASE depends_on:MBEDTLS_MD4_C */
|
2013-08-20 09:48:36 +00:00
|
|
|
void md4_text( char *text_src_string, char *hex_hash_string )
|
2009-06-28 21:50:27 +00:00
|
|
|
{
|
2017-06-28 09:51:17 +00:00
|
|
|
int ret;
|
2014-01-17 13:23:48 +00:00
|
|
|
unsigned char src_str[100];
|
|
|
|
unsigned char hash_str[33];
|
|
|
|
unsigned char output[16];
|
2009-06-28 21:50:27 +00:00
|
|
|
|
2014-01-17 13:23:48 +00:00
|
|
|
memset( src_str, 0x00, sizeof src_str );
|
|
|
|
memset( hash_str, 0x00, sizeof hash_str );
|
|
|
|
memset( output, 0x00, sizeof output );
|
2009-06-28 21:50:27 +00:00
|
|
|
|
2014-04-17 14:06:37 +00:00
|
|
|
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
|
2009-06-28 21:50:27 +00:00
|
|
|
|
2017-06-28 09:51:17 +00:00
|
|
|
ret = mbedtls_md4_ext( src_str, strlen( (char *) src_str ), output );
|
|
|
|
TEST_ASSERT( ret == 0 );
|
2014-01-17 13:23:48 +00:00
|
|
|
hexify( hash_str, output, sizeof output );
|
2009-06-28 21:50:27 +00:00
|
|
|
|
2013-08-20 09:48:36 +00:00
|
|
|
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
2009-06-28 21:50:27 +00:00
|
|
|
}
|
2013-08-20 09:48:36 +00:00
|
|
|
/* END_CASE */
|
2009-06-28 21:50:27 +00:00
|
|
|
|
2015-04-08 10:49:31 +00:00
|
|
|
/* BEGIN_CASE depends_on:MBEDTLS_MD5_C */
|
2013-08-20 09:48:36 +00:00
|
|
|
void md5_text( char *text_src_string, char *hex_hash_string )
|
2009-06-28 21:50:27 +00:00
|
|
|
{
|
2017-06-28 09:51:17 +00:00
|
|
|
int ret;
|
2014-01-17 13:23:48 +00:00
|
|
|
unsigned char src_str[100];
|
|
|
|
unsigned char hash_str[33];
|
|
|
|
unsigned char output[16];
|
2009-06-28 21:50:27 +00:00
|
|
|
|
2014-01-17 13:23:48 +00:00
|
|
|
memset( src_str, 0x00, sizeof src_str );
|
|
|
|
memset( hash_str, 0x00, sizeof hash_str );
|
|
|
|
memset( output, 0x00, sizeof output );
|
2009-06-28 21:50:27 +00:00
|
|
|
|
2014-04-17 14:06:37 +00:00
|
|
|
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
|
2009-06-28 21:50:27 +00:00
|
|
|
|
2017-06-28 09:51:17 +00:00
|
|
|
ret = mbedtls_md5_ext( src_str, strlen( (char *) src_str ), output );
|
|
|
|
TEST_ASSERT( ret == 0 );
|
2014-01-17 13:23:48 +00:00
|
|
|
hexify( hash_str, output, sizeof output );
|
2009-06-28 21:50:27 +00:00
|
|
|
|
2013-08-20 09:48:36 +00:00
|
|
|
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
2009-06-28 21:50:27 +00:00
|
|
|
}
|
2013-08-20 09:48:36 +00:00
|
|
|
/* END_CASE */
|
2009-07-06 06:40:23 +00:00
|
|
|
|
2015-04-08 10:49:31 +00:00
|
|
|
/* BEGIN_CASE depends_on:MBEDTLS_RIPEMD160_C */
|
2014-01-22 12:35:29 +00:00
|
|
|
void ripemd160_text( char *text_src_string, char *hex_hash_string )
|
2014-01-17 11:42:35 +00:00
|
|
|
{
|
2017-06-28 09:51:17 +00:00
|
|
|
int ret;
|
2014-01-17 13:23:48 +00:00
|
|
|
unsigned char src_str[100];
|
2014-01-17 11:42:35 +00:00
|
|
|
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);
|
|
|
|
|
2014-04-17 14:06:37 +00:00
|
|
|
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
|
2014-01-17 11:42:35 +00:00
|
|
|
|
2017-06-28 09:51:17 +00:00
|
|
|
ret = mbedtls_ripemd160_ext( src_str, strlen( (char *) src_str ), output );
|
|
|
|
TEST_ASSERT( ret == 0 );
|
2014-01-17 11:42:35 +00:00
|
|
|
hexify( hash_str, output, sizeof output );
|
|
|
|
|
|
|
|
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
|
|
|
}
|
|
|
|
/* END_CASE */
|
|
|
|
|
2015-04-08 10:49:31 +00:00
|
|
|
/* BEGIN_CASE depends_on:MBEDTLS_MD2_C:MBEDTLS_SELF_TEST */
|
2013-08-20 09:48:36 +00:00
|
|
|
void md2_selftest()
|
2009-07-06 06:40:23 +00:00
|
|
|
{
|
2016-09-09 08:10:28 +00:00
|
|
|
TEST_ASSERT( mbedtls_md2_self_test( 1 ) == 0 );
|
2009-07-06 06:40:23 +00:00
|
|
|
}
|
2013-08-20 09:48:36 +00:00
|
|
|
/* END_CASE */
|
2009-07-06 06:40:23 +00:00
|
|
|
|
2015-04-08 10:49:31 +00:00
|
|
|
/* BEGIN_CASE depends_on:MBEDTLS_MD4_C:MBEDTLS_SELF_TEST */
|
2013-08-20 09:48:36 +00:00
|
|
|
void md4_selftest()
|
2009-07-06 06:40:23 +00:00
|
|
|
{
|
2016-09-09 08:10:28 +00:00
|
|
|
TEST_ASSERT( mbedtls_md4_self_test( 1 ) == 0 );
|
2009-07-06 06:40:23 +00:00
|
|
|
}
|
2013-08-20 09:48:36 +00:00
|
|
|
/* END_CASE */
|
2009-07-06 06:40:23 +00:00
|
|
|
|
2015-04-08 10:49:31 +00:00
|
|
|
/* BEGIN_CASE depends_on:MBEDTLS_MD5_C:MBEDTLS_SELF_TEST */
|
2013-08-20 09:48:36 +00:00
|
|
|
void md5_selftest()
|
2009-07-06 06:40:23 +00:00
|
|
|
{
|
2016-09-09 08:10:28 +00:00
|
|
|
TEST_ASSERT( mbedtls_md5_self_test( 1 ) == 0 );
|
2009-07-06 06:40:23 +00:00
|
|
|
}
|
2013-08-20 09:48:36 +00:00
|
|
|
/* END_CASE */
|
2014-01-17 11:42:35 +00:00
|
|
|
|
2015-04-08 10:49:31 +00:00
|
|
|
/* BEGIN_CASE depends_on:MBEDTLS_RIPEMD160_C:MBEDTLS_SELF_TEST */
|
2014-01-22 12:35:29 +00:00
|
|
|
void ripemd160_selftest()
|
2014-01-17 11:42:35 +00:00
|
|
|
{
|
2016-09-09 08:10:28 +00:00
|
|
|
TEST_ASSERT( mbedtls_ripemd160_self_test( 1 ) == 0 );
|
2014-01-17 11:42:35 +00:00
|
|
|
}
|
|
|
|
/* END_CASE */
|