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>
This commit is contained in:
parent
a3f99591f6
commit
46e8fd8263
3 changed files with 19 additions and 5 deletions
|
@ -243,6 +243,9 @@ const selftest_t selftests[] =
|
|||
#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
|
||||
|
|
|
@ -169,6 +169,10 @@ SHA-1 Selftest
|
|||
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:
|
||||
|
|
|
@ -46,9 +46,9 @@ void sha224( data_t * src_str, data_t * hash )
|
|||
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 @@ void mbedtls_sha256( data_t * src_str, data_t * hash )
|
|||
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 @@ void sha1_selftest( )
|
|||
}
|
||||
/* 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 */
|
||||
|
||||
|
|
Loading…
Reference in a new issue