test: sha: test SHA224 and SHA256 separately
This is meant to adapt to the new library design in which
SHA224 and SHA256 can be built independently from each other.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
diff --git a/programs/test/selftest.c b/programs/test/selftest.c
index 163fda9..de1ee0f 100644
--- a/programs/test/selftest.c
+++ b/programs/test/selftest.c
@@ -243,6 +243,9 @@
#if defined(MBEDTLS_SHA1_C)
{"sha1", mbedtls_sha1_self_test},
#endif
+#if defined(MBEDTLS_SHA224_C)
+ {"sha256", mbedtls_sha224_self_test},
+#endif
#if defined(MBEDTLS_SHA256_C)
{"sha256", mbedtls_sha256_self_test},
#endif
diff --git a/tests/suites/test_suite_shax.data b/tests/suites/test_suite_shax.data
index dce9b7d..2af85c3 100644
--- a/tests/suites/test_suite_shax.data
+++ b/tests/suites/test_suite_shax.data
@@ -169,6 +169,10 @@
depends_on:MBEDTLS_SELF_TEST:MBEDTLS_SHA1_C
sha1_selftest:
+SHA-224 Selftest
+depends_on:MBEDTLS_SELF_TEST:MBEDTLS_SHA224_C
+sha224_selftest:
+
SHA-256 Selftest
depends_on:MBEDTLS_SELF_TEST:MBEDTLS_SHA256_C
sha256_selftest:
diff --git a/tests/suites/test_suite_shax.function b/tests/suites/test_suite_shax.function
index c3c1708..79afe01 100644
--- a/tests/suites/test_suite_shax.function
+++ b/tests/suites/test_suite_shax.function
@@ -46,9 +46,9 @@
memset(output, 0x00, 57);
- TEST_ASSERT( mbedtls_sha256( src_str->x, src_str->len, output, 1 ) == 0 );
+ TEST_EQUAL( mbedtls_sha256( src_str->x, src_str->len, output, 1 ), 0 );
- TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, 28, hash->len ) == 0 );
+ TEST_EQUAL( mbedtls_test_hexcmp( output, hash->x, 28, hash->len ), 0 );
}
/* END_CASE */
@@ -60,9 +60,9 @@
memset(output, 0x00, 65);
- TEST_ASSERT( mbedtls_sha256( src_str->x, src_str->len, output, 0 ) == 0 );
+ TEST_EQUAL( mbedtls_sha256( src_str->x, src_str->len, output, 0 ), 0 );
- TEST_ASSERT( mbedtls_test_hexcmp( output, hash->x, 32, hash->len ) == 0 );
+ TEST_EQUAL( mbedtls_test_hexcmp( output, hash->x, 32, hash->len ), 0 );
}
/* END_CASE */
@@ -121,10 +121,17 @@
}
/* END_CASE */
+/* BEGIN_CASE depends_on:MBEDTLS_SHA224_C:MBEDTLS_SELF_TEST */
+void sha224_selftest( )
+{
+ TEST_EQUAL( mbedtls_sha224_self_test( 1 ), 0 );
+}
+/* END_CASE */
+
/* BEGIN_CASE depends_on:MBEDTLS_SHA256_C:MBEDTLS_SELF_TEST */
void sha256_selftest( )
{
- TEST_ASSERT( mbedtls_sha256_self_test( 1 ) == 0 );
+ TEST_EQUAL( mbedtls_sha256_self_test( 1 ), 0 );
}
/* END_CASE */