From f3013830cc43d57bbcefb546c55a810a96a02c5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Sat, 29 Mar 2014 15:54:50 +0100 Subject: [PATCH] Tests for MD info functions --- tests/suites/test_suite_md.data | 39 +++++++++++++++++++++++++++++ tests/suites/test_suite_md.function | 31 +++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/tests/suites/test_suite_md.data b/tests/suites/test_suite_md.data index 349e18fc0..cb0281488 100644 --- a/tests/suites/test_suite_md.data +++ b/tests/suites/test_suite_md.data @@ -1,3 +1,42 @@ +MD list +md_list: + +Information on MD2 +depends_on:POLARSSL_MD2_C +md_info:POLARSSL_MD_MD2:"MD2":16 + +Information on MD4 +depends_on:POLARSSL_MD4_C +md_info:POLARSSL_MD_MD4:"MD4":16 + +Information on MD5 +depends_on:POLARSSL_MD5_C +md_info:POLARSSL_MD_MD5:"MD5":16 + +Information on RIPEMD160 +depends_on:POLARSSL_RIPEMD160_C +md_info:POLARSSL_MD_RIPEMD160:"RIPEMD160":20 + +Information on SHA1 +depends_on:POLARSSL_SHA1_C +md_info:POLARSSL_MD_SHA1:"SHA1":20 + +Information on SHA224 +depends_on:POLARSSL_SHA256_C +md_info:POLARSSL_MD_SHA224:"SHA224":28 + +Information on SHA256 +depends_on:POLARSSL_SHA256_C +md_info:POLARSSL_MD_SHA256:"SHA256":32 + +Information on SHA384 +depends_on:POLARSSL_SHA512_C +md_info:POLARSSL_MD_SHA384:"SHA384":48 + +Information on SHA512 +depends_on:POLARSSL_SHA512_C +md_info:POLARSSL_MD_SHA512:"SHA512":64 + generic md2 Test vector RFC1319 #1 depends_on:POLARSSL_MD2_C md_text:"md2":"":"8350e5a3e24c153df2275c9f80692773" diff --git a/tests/suites/test_suite_md.function b/tests/suites/test_suite_md.function index 502df4533..1931154b1 100644 --- a/tests/suites/test_suite_md.function +++ b/tests/suites/test_suite_md.function @@ -7,6 +7,37 @@ * END_DEPENDENCIES */ +/* BEGIN_CASE */ +void md_list( ) +{ + const int *md_type_ptr; + + for( md_type_ptr = md_list(); *md_type_ptr != 0; md_type_ptr++ ) + TEST_ASSERT( md_info_from_type( *md_type_ptr ) != NULL ); +} +/* END_CASE */ + +/* BEGIN_CASE */ +void md_info( int md_type, char *md_name, int md_size ) +{ + const md_info_t *md_info; + const int *md_type_ptr; + int found; + + TEST_ASSERT( ( md_info = md_info_from_type( md_type ) ) != NULL ); + TEST_ASSERT( md_info == md_info_from_string( md_name ) ); + + TEST_ASSERT( md_get_type( md_info ) == (md_type_t) md_type ); + TEST_ASSERT( md_get_size( md_info ) == (unsigned char) md_size ); + + found = 0; + for( md_type_ptr = md_list(); *md_type_ptr != 0; md_type_ptr++ ) + if( *md_type_ptr == md_type ) + found = 1; + TEST_ASSERT( found == 1 ); +} +/* END_CASE */ + /* BEGIN_CASE */ void md_text( char *text_md_name, char *text_src_string, char *hex_hash_string ) {