Test SHA-512 parameter validation
diff --git a/tests/suites/test_suite_shax.function b/tests/suites/test_suite_shax.function
index 147ae0e..a5a7b68 100644
--- a/tests/suites/test_suite_shax.function
+++ b/tests/suites/test_suite_shax.function
@@ -46,6 +46,62 @@
}
/* END_CASE */
+/* BEGIN_CASE depends_on:MBEDTLS_SHA256_C */
+void sha512_valid_param( )
+{
+ TEST_VALID_PARAM( mbedtls_sha512_free( NULL ) );
+}
+/* END_CASE */
+
+/* BEGIN_CASE depends_on:MBEDTLS_SHA512_C:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
+void sha512_invalid_param( )
+{
+ mbedtls_sha512_context ctx;
+ unsigned char buf[64] = { 0 };
+ size_t const buflen = sizeof( buf );
+ int valid_type = 0;
+ int invalid_type = 42;
+
+ TEST_INVALID_PARAM( mbedtls_sha512_init( NULL ) );
+
+ TEST_INVALID_PARAM( mbedtls_sha512_clone( NULL, &ctx ) );
+ TEST_INVALID_PARAM( mbedtls_sha512_clone( &ctx, NULL ) );
+
+ TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
+ mbedtls_sha512_starts_ret( NULL, valid_type ) );
+ TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
+ mbedtls_sha512_starts_ret( &ctx, invalid_type ) );
+
+ TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
+ mbedtls_sha512_update_ret( NULL, buf, buflen ) );
+ TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
+ mbedtls_sha512_update_ret( &ctx, NULL, buflen ) );
+
+ TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
+ mbedtls_sha512_finish_ret( NULL, buf ) );
+ TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
+ mbedtls_sha512_finish_ret( &ctx, NULL ) );
+
+ TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
+ mbedtls_internal_sha512_process( NULL, buf ) );
+ TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
+ mbedtls_internal_sha512_process( &ctx, NULL ) );
+
+ TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
+ mbedtls_sha512_ret( NULL, buflen,
+ buf, valid_type ) );
+ TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
+ mbedtls_sha512_ret( buf, buflen,
+ NULL, valid_type ) );
+ TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA,
+ mbedtls_sha512_ret( buf, buflen,
+ buf, invalid_type ) );
+
+exit:
+ return;
+}
+/* END_CASE */
+
/* BEGIN_CASE depends_on:MBEDTLS_SHA512_C */
void sha384( data_t * src_str, data_t * hex_hash_string )
{