Change test suites to use new MD API with ret code
This commit is contained in:
parent
cccfe08530
commit
b71b630730
@ -8,6 +8,7 @@
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_MD2_C */
|
||||
void md2_text( char *text_src_string, char *hex_hash_string )
|
||||
{
|
||||
int ret;
|
||||
unsigned char src_str[100];
|
||||
unsigned char hash_str[33];
|
||||
unsigned char output[16];
|
||||
@ -18,7 +19,8 @@ void md2_text( char *text_src_string, char *hex_hash_string )
|
||||
|
||||
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
|
||||
|
||||
mbedtls_md2( src_str, strlen( (char *) src_str ), output );
|
||||
ret = mbedtls_md2_ext( src_str, strlen( (char *) src_str ), output );
|
||||
TEST_ASSERT( ret == 0 ) ;
|
||||
hexify( hash_str, output, sizeof output );
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
||||
@ -28,6 +30,7 @@ void md2_text( char *text_src_string, char *hex_hash_string )
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_MD4_C */
|
||||
void md4_text( char *text_src_string, char *hex_hash_string )
|
||||
{
|
||||
int ret;
|
||||
unsigned char src_str[100];
|
||||
unsigned char hash_str[33];
|
||||
unsigned char output[16];
|
||||
@ -38,7 +41,8 @@ void md4_text( char *text_src_string, char *hex_hash_string )
|
||||
|
||||
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
|
||||
|
||||
mbedtls_md4( src_str, strlen( (char *) src_str ), output );
|
||||
ret = mbedtls_md4_ext( src_str, strlen( (char *) src_str ), output );
|
||||
TEST_ASSERT( ret == 0 );
|
||||
hexify( hash_str, output, sizeof output );
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
||||
@ -48,6 +52,7 @@ void md4_text( char *text_src_string, char *hex_hash_string )
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_MD5_C */
|
||||
void md5_text( char *text_src_string, char *hex_hash_string )
|
||||
{
|
||||
int ret;
|
||||
unsigned char src_str[100];
|
||||
unsigned char hash_str[33];
|
||||
unsigned char output[16];
|
||||
@ -58,7 +63,8 @@ void md5_text( char *text_src_string, char *hex_hash_string )
|
||||
|
||||
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
|
||||
|
||||
mbedtls_md5( src_str, strlen( (char *) src_str ), output );
|
||||
ret = mbedtls_md5_ext( src_str, strlen( (char *) src_str ), output );
|
||||
TEST_ASSERT( ret == 0 );
|
||||
hexify( hash_str, output, sizeof output );
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
||||
@ -68,6 +74,7 @@ void md5_text( char *text_src_string, char *hex_hash_string )
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_RIPEMD160_C */
|
||||
void ripemd160_text( char *text_src_string, char *hex_hash_string )
|
||||
{
|
||||
int ret;
|
||||
unsigned char src_str[100];
|
||||
unsigned char hash_str[41];
|
||||
unsigned char output[20];
|
||||
@ -78,7 +85,8 @@ void ripemd160_text( char *text_src_string, char *hex_hash_string )
|
||||
|
||||
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
|
||||
|
||||
mbedtls_ripemd160( src_str, strlen( (char *) src_str ), output );
|
||||
ret = mbedtls_ripemd160_ext( src_str, strlen( (char *) src_str ), output );
|
||||
TEST_ASSERT( ret == 0 );
|
||||
hexify( hash_str, output, sizeof output );
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
||||
|
@ -18,7 +18,7 @@ void mbedtls_sha1( char *hex_src_string, char *hex_hash_string )
|
||||
|
||||
src_len = unhexify( src_str, hex_src_string );
|
||||
|
||||
mbedtls_sha1( src_str, src_len, output );
|
||||
TEST_ASSERT( mbedtls_sha1_ext( src_str, src_len, output ) == 0 );
|
||||
hexify( hash_str, output, 20 );
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
||||
@ -39,7 +39,7 @@ void sha224(char *hex_src_string, char *hex_hash_string )
|
||||
|
||||
src_len = unhexify( src_str, hex_src_string );
|
||||
|
||||
mbedtls_sha256( src_str, src_len, output, 1 );
|
||||
TEST_ASSERT( mbedtls_sha256_ext( src_str, src_len, output, 1 ) == 0 );
|
||||
hexify( hash_str, output, 28 );
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
||||
@ -60,7 +60,7 @@ void mbedtls_sha256(char *hex_src_string, char *hex_hash_string )
|
||||
|
||||
src_len = unhexify( src_str, hex_src_string );
|
||||
|
||||
mbedtls_sha256( src_str, src_len, output, 0 );
|
||||
TEST_ASSERT( mbedtls_sha256_ext( src_str, src_len, output, 0 ) == 0 );
|
||||
hexify( hash_str, output, 32 );
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
||||
@ -81,7 +81,7 @@ void sha384(char *hex_src_string, char *hex_hash_string )
|
||||
|
||||
src_len = unhexify( src_str, hex_src_string );
|
||||
|
||||
mbedtls_sha512( src_str, src_len, output, 1 );
|
||||
TEST_ASSERT( mbedtls_sha512_ext( src_str, src_len, output, 1 ) == 0 );
|
||||
hexify( hash_str, output, 48 );
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
||||
@ -102,7 +102,7 @@ void mbedtls_sha512(char *hex_src_string, char *hex_hash_string )
|
||||
|
||||
src_len = unhexify( src_str, hex_src_string );
|
||||
|
||||
mbedtls_sha512( src_str, src_len, output, 0);
|
||||
TEST_ASSERT( mbedtls_sha512_ext( src_str, src_len, output, 0 ) == 0 );
|
||||
hexify( hash_str, output, 64 );
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
|
||||
|
Loading…
Reference in New Issue
Block a user