md: Add parameter validation

Improve documentation on parameter constraints
This commit is contained in:
Unknown 2018-12-14 04:50:14 -05:00
parent a4251f4775
commit ebb8f56f22
3 changed files with 101 additions and 93 deletions

View file

@ -109,7 +109,7 @@ const int *mbedtls_md_list( void );
* \brief This function returns the message-digest information
* associated with the given digest name.
*
* \param md_name The name of the digest to search for.
* \param md_name The name of the digest to search for. This must not be \c NULL.
*
* \return The message-digest information associated with \p md_name.
* \return NULL if the associated message-digest information is not found.
@ -120,7 +120,7 @@ const mbedtls_md_info_t *mbedtls_md_info_from_string( const char *md_name );
* \brief This function returns the message-digest information
* associated with the given digest type.
*
* \param md_type The type of digest to search for.
* \param md_type The type of digest to search for. This must not be \c NULL.
*
* \return The message-digest information associated with \p md_type.
* \return NULL if the associated message-digest information is not found.
@ -133,7 +133,7 @@ const mbedtls_md_info_t *mbedtls_md_info_from_type( mbedtls_md_type_t md_type );
*
* This function should always be called first. It prepares the
* context for mbedtls_md_setup() for binding it to a
* message-digest algorithm.
* message-digest algorithm. The \p ctx must not be \c NULL.
*/
void mbedtls_md_init( mbedtls_md_context_t *ctx );
@ -148,7 +148,7 @@ void mbedtls_md_init( mbedtls_md_context_t *ctx );
* Calling this function if you have previously
* called mbedtls_md_init() and nothing else is optional.
* You must not call this function if you have not called
* mbedtls_md_init().
* mbedtls_md_init(). The \p ctx must not be \c NULL.
*/
void mbedtls_md_free( mbedtls_md_context_t *ctx );
@ -167,7 +167,7 @@ void mbedtls_md_free( mbedtls_md_context_t *ctx );
*
* \deprecated Superseded by mbedtls_md_setup() in 2.0.0
*
* \param ctx The context to set up.
* \param ctx The context to set up. This must not be \c NULL.
* \param md_info The information structure of the message-digest algorithm
* to use.
*
@ -188,9 +188,9 @@ int mbedtls_md_init_ctx( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_
* mbedtls_md_free(). Makes it necessary to call
* mbedtls_md_free() later.
*
* \param ctx The context to set up.
* \param ctx The context to set up. This must not be \c NULL.
* \param md_info The information structure of the message-digest algorithm
* to use.
* to use. This must not be \c NULL.
* \param hmac Defines if HMAC is used. 0: HMAC is not used (saves some memory),
* or non-zero: HMAC is used with this context.
*
@ -214,8 +214,8 @@ int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_inf
* \warning This function clones the message-digest state, not the
* HMAC state.
*
* \param dst The destination context.
* \param src The context to be cloned.
* \param dst The destination context. This must not be \c NULL.
* \param src The context to be cloned. This must not be \c NULL.
*
* \return \c 0 on success.
* \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification failure.
@ -228,7 +228,7 @@ int mbedtls_md_clone( mbedtls_md_context_t *dst,
* message-digest information structure.
*
* \param md_info The information structure of the message-digest algorithm
* to use.
* to use. This must not be \c NULL.
*
* \return The size of the message-digest output in Bytes.
*/
@ -239,7 +239,7 @@ unsigned char mbedtls_md_get_size( const mbedtls_md_info_t *md_info );
* message-digest information structure.
*
* \param md_info The information structure of the message-digest algorithm
* to use.
* to use. This must not be \c NULL.
*
* \return The type of the message digest.
*/
@ -250,7 +250,7 @@ mbedtls_md_type_t mbedtls_md_get_type( const mbedtls_md_info_t *md_info );
* message-digest information structure.
*
* \param md_info The information structure of the message-digest algorithm
* to use.
* to use. This must not be \c NULL.
*
* \return The name of the message digest.
*/
@ -280,7 +280,7 @@ int mbedtls_md_starts( mbedtls_md_context_t *ctx );
* Afterwards, call mbedtls_md_finish().
*
* \param ctx The generic message-digest context.
* \param input The buffer holding the input data.
* \param input The buffer holding the input data. This must not be \c NULL.
* \param ilen The length of the input data.
*
* \return \c 0 on success.
@ -302,6 +302,7 @@ int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, si
*
* \param ctx The generic message-digest context.
* \param output The buffer for the generic message-digest checksum result.
* This must not be \c NULL.
*
* \return \c 0 on success.
* \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification
@ -318,10 +319,11 @@ int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output );
* Output = message_digest(input buffer).
*
* \param md_info The information structure of the message-digest algorithm
* to use.
* to use. This must not be \c NULL.
* \param input The buffer holding the data.
* \param ilen The length of the input data.
* \param output The generic message-digest checksum result.
* This must not be \c NULL.
*
* \return \c 0 on success.
* \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification
@ -339,9 +341,10 @@ int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, si
* Output = message_digest(file contents).
*
* \param md_info The information structure of the message-digest algorithm
* to use.
* \param path The input file name.
* to use. This must not be \c NULL.
* \param path The input file name. This must not be \c NULL.
* \param output The generic message-digest checksum result.
* This must not be \c NULL.
*
* \return \c 0 on success.
* \return #MBEDTLS_ERR_MD_FILE_IO_ERROR on an I/O error accessing
@ -363,7 +366,7 @@ int mbedtls_md_file( const mbedtls_md_info_t *md_info, const char *path,
*
* \param ctx The message digest context containing an embedded HMAC
* context.
* \param key The HMAC secret key.
* \param key The HMAC secret key. This must not be \c NULL.
* \param keylen The length of the HMAC key in Bytes.
*
* \return \c 0 on success.
@ -407,7 +410,7 @@ int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *inpu
*
* \param ctx The message digest context containing an embedded HMAC
* context.
* \param output The generic HMAC checksum result.
* \param output The generic HMAC checksum result. This must not be \c NULL.
*
* \return \c 0 on success.
* \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification
@ -424,7 +427,7 @@ int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output);
* input.
*
* \param ctx The message digest context containing an embedded HMAC
* context.
* context. This must not be \c NULL.
*
* \return \c 0 on success.
* \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification
@ -443,12 +446,12 @@ int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx );
* output = generic HMAC(hmac key, input buffer).
*
* \param md_info The information structure of the message-digest algorithm
* to use.
* \param key The HMAC secret key.
* to use. This must not be \c NULL.
* \param key The HMAC secret key. This must not be \c NULL.
* \param keylen The length of the HMAC secret key in Bytes.
* \param input The buffer holding the input data.
* \param ilen The length of the input data.
* \param output The generic HMAC result.
* \param output The generic HMAC result. This must not be \c NULL.
*
* \return \c 0 on success.
* \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification

View file

@ -49,6 +49,12 @@
#include <stdio.h>
#endif
#define MBEDTLS_MD_VALIDATE_RET(cond) \
MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_MD_BAD_INPUT_DATA )
#define MBEDTLS_MD_VALIDATE_RET_NULL(cond) \
MBEDTLS_INTERNAL_VALIDATE_RET( cond, NULL )
#define MBEDTLS_MD_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE( cond )
/*
* Reminder: update profiles in x509_crt.c when adding a new hash!
*/
@ -94,8 +100,7 @@ const int *mbedtls_md_list( void )
const mbedtls_md_info_t *mbedtls_md_info_from_string( const char *md_name )
{
if( NULL == md_name )
return( NULL );
MBEDTLS_MD_VALIDATE_RET_NULL( md_name != NULL );
/* Get the appropriate digest information */
#if defined(MBEDTLS_MD2_C)
@ -176,6 +181,7 @@ const mbedtls_md_info_t *mbedtls_md_info_from_type( mbedtls_md_type_t md_type )
void mbedtls_md_init( mbedtls_md_context_t *ctx )
{
MBEDTLS_MD_VALIDATE( ctx != NULL );
memset( ctx, 0, sizeof( mbedtls_md_context_t ) );
}
@ -200,12 +206,11 @@ void mbedtls_md_free( mbedtls_md_context_t *ctx )
int mbedtls_md_clone( mbedtls_md_context_t *dst,
const mbedtls_md_context_t *src )
{
if( dst == NULL || dst->md_info == NULL ||
src == NULL || src->md_info == NULL ||
dst->md_info != src->md_info )
{
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
}
MBEDTLS_MD_VALIDATE_RET( dst != NULL );
MBEDTLS_MD_VALIDATE_RET( src != NULL );
MBEDTLS_MD_VALIDATE_RET( dst->md_info != NULL );
MBEDTLS_MD_VALIDATE_RET( src->md_info != NULL );
MBEDTLS_MD_VALIDATE_RET( dst->md_info == src->md_info );
dst->md_info->clone_func( dst->md_ctx, src->md_ctx );
@ -221,8 +226,8 @@ int mbedtls_md_init_ctx( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_
int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac )
{
if( md_info == NULL || ctx == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
MBEDTLS_MD_VALIDATE_RET( md_info != NULL );
MBEDTLS_MD_VALIDATE_RET( ctx != NULL );
if( ( ctx->md_ctx = md_info->ctx_alloc_func() ) == NULL )
return( MBEDTLS_ERR_MD_ALLOC_FAILED );
@ -244,24 +249,26 @@ int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_inf
int mbedtls_md_starts( mbedtls_md_context_t *ctx )
{
if( ctx == NULL || ctx->md_info == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
MBEDTLS_MD_VALIDATE_RET( ctx != NULL );
MBEDTLS_MD_VALIDATE_RET( ctx->md_info != NULL );
return( ctx->md_info->starts_func( ctx->md_ctx ) );
}
int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen )
{
if( ctx == NULL || ctx->md_info == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
MBEDTLS_MD_VALIDATE_RET( ctx != NULL );
MBEDTLS_MD_VALIDATE_RET( ctx->md_info != NULL );
MBEDTLS_MD_VALIDATE_RET( input != NULL );
return( ctx->md_info->update_func( ctx->md_ctx, input, ilen ) );
}
int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output )
{
if( ctx == NULL || ctx->md_info == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
MBEDTLS_MD_VALIDATE_RET( ctx != NULL );
MBEDTLS_MD_VALIDATE_RET( ctx->md_info != NULL );
MBEDTLS_MD_VALIDATE_RET( output != NULL );
return( ctx->md_info->finish_func( ctx->md_ctx, output ) );
}
@ -269,8 +276,8 @@ int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output )
int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen,
unsigned char *output )
{
if( md_info == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
MBEDTLS_MD_VALIDATE_RET( md_info != NULL );
MBEDTLS_MD_VALIDATE_RET( output != NULL );
return( md_info->digest_func( input, ilen, output ) );
}
@ -284,8 +291,9 @@ int mbedtls_md_file( const mbedtls_md_info_t *md_info, const char *path, unsigne
mbedtls_md_context_t ctx;
unsigned char buf[1024];
if( md_info == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
MBEDTLS_MD_VALIDATE_RET( md_info != NULL );
MBEDTLS_MD_VALIDATE_RET( path != NULL );
MBEDTLS_MD_VALIDATE_RET( output != NULL );
if( ( f = fopen( path, "rb" ) ) == NULL )
return( MBEDTLS_ERR_MD_FILE_IO_ERROR );
@ -323,8 +331,10 @@ int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key,
unsigned char *ipad, *opad;
size_t i;
if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
MBEDTLS_MD_VALIDATE_RET( ctx != NULL );
MBEDTLS_MD_VALIDATE_RET( ctx->md_info != NULL );
MBEDTLS_MD_VALIDATE_RET( ctx->hmac_ctx != NULL );
MBEDTLS_MD_VALIDATE_RET( key != NULL );
if( keylen > (size_t) ctx->md_info->block_size )
{
@ -365,8 +375,9 @@ cleanup:
int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen )
{
if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
MBEDTLS_MD_VALIDATE_RET( ctx != NULL );
MBEDTLS_MD_VALIDATE_RET( ctx->hmac_ctx != NULL );
MBEDTLS_MD_VALIDATE_RET( ctx->md_info != NULL );
return( ctx->md_info->update_func( ctx->md_ctx, input, ilen ) );
}
@ -377,8 +388,10 @@ int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output )
unsigned char tmp[MBEDTLS_MD_MAX_SIZE];
unsigned char *opad;
if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
MBEDTLS_MD_VALIDATE_RET( ctx != NULL );
MBEDTLS_MD_VALIDATE_RET( ctx->hmac_ctx != NULL );
MBEDTLS_MD_VALIDATE_RET( ctx->md_info != NULL );
MBEDTLS_MD_VALIDATE_RET( output != NULL );
opad = (unsigned char *) ctx->hmac_ctx + ctx->md_info->block_size;
@ -400,8 +413,9 @@ int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx )
int ret;
unsigned char *ipad;
if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
MBEDTLS_MD_VALIDATE_RET( ctx != NULL );
MBEDTLS_MD_VALIDATE_RET( ctx->hmac_ctx != NULL );
MBEDTLS_MD_VALIDATE_RET( ctx->md_info != NULL );
ipad = (unsigned char *) ctx->hmac_ctx;
@ -419,8 +433,9 @@ int mbedtls_md_hmac( const mbedtls_md_info_t *md_info,
mbedtls_md_context_t ctx;
int ret;
if( md_info == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
MBEDTLS_MD_VALIDATE_RET( md_info != NULL );
MBEDTLS_MD_VALIDATE_RET( key != NULL );
MBEDTLS_MD_VALIDATE_RET( output != NULL );
mbedtls_md_init( &ctx );
@ -442,32 +457,29 @@ cleanup:
int mbedtls_md_process( mbedtls_md_context_t *ctx, const unsigned char *data )
{
if( ctx == NULL || ctx->md_info == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
MBEDTLS_MD_VALIDATE_RET( ctx != NULL );
MBEDTLS_MD_VALIDATE_RET( ctx->md_info != NULL );
return( ctx->md_info->process_func( ctx->md_ctx, data ) );
}
unsigned char mbedtls_md_get_size( const mbedtls_md_info_t *md_info )
{
if( md_info == NULL )
return( 0 );
MBEDTLS_INTERNAL_VALIDATE_RET( md_info != NULL, 0 );
return md_info->size;
}
mbedtls_md_type_t mbedtls_md_get_type( const mbedtls_md_info_t *md_info )
{
if( md_info == NULL )
return( MBEDTLS_MD_NONE );
MBEDTLS_INTERNAL_VALIDATE_RET( md_info != NULL, MBEDTLS_MD_NONE );
return md_info->type;
}
const char *mbedtls_md_get_name( const mbedtls_md_info_t *md_info )
{
if( md_info == NULL )
return( NULL );
MBEDTLS_MD_VALIDATE_RET_NULL( md_info != NULL );
return md_info->name;
}

View file

@ -39,7 +39,7 @@ exit:
}
/* END_CASE */
/* BEGIN_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
void md_null_args( )
{
mbedtls_md_context_t ctx;
@ -48,53 +48,46 @@ void md_null_args( )
mbedtls_md_init( &ctx );
TEST_ASSERT( mbedtls_md_get_size( NULL ) == 0 );
TEST_ASSERT( mbedtls_md_get_type( NULL ) == MBEDTLS_MD_NONE );
TEST_ASSERT( mbedtls_md_get_name( NULL ) == NULL );
TEST_INVALID_PARAM( mbedtls_md_get_size( NULL ) == 0 );
TEST_INVALID_PARAM( mbedtls_md_get_type( NULL ) == MBEDTLS_MD_NONE );
TEST_INVALID_PARAM( mbedtls_md_get_name( NULL ) == NULL );
TEST_ASSERT( mbedtls_md_info_from_string( NULL ) == NULL );
TEST_INVALID_PARAM( mbedtls_md_info_from_string( NULL ) == NULL );
TEST_ASSERT( mbedtls_md_setup( &ctx, NULL, 0 ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_ASSERT( mbedtls_md_setup( NULL, info, 0 ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_INVALID_PARAM( mbedtls_md_setup( &ctx, NULL, 0 ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_INVALID_PARAM( mbedtls_md_setup( NULL, info, 0 ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_ASSERT( mbedtls_md_starts( NULL ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_ASSERT( mbedtls_md_starts( &ctx ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_INVALID_PARAM( mbedtls_md_starts( NULL ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_INVALID_PARAM( mbedtls_md_starts( &ctx ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_ASSERT( mbedtls_md_update( NULL, buf, 1 ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_ASSERT( mbedtls_md_update( &ctx, buf, 1 ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_INVALID_PARAM( mbedtls_md_update( NULL, buf, 1 ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_INVALID_PARAM( mbedtls_md_update( &ctx, buf, 1 ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_ASSERT( mbedtls_md_finish( NULL, buf ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_ASSERT( mbedtls_md_finish( &ctx, buf ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_INVALID_PARAM( mbedtls_md_finish( NULL, buf ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_INVALID_PARAM( mbedtls_md_finish( &ctx, buf ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_ASSERT( mbedtls_md( NULL, buf, 1, buf ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_INVALID_PARAM( mbedtls_md( NULL, buf, 1, buf ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
#if defined(MBEDTLS_FS_IO)
TEST_ASSERT( mbedtls_md_file( NULL, "", buf ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_INVALID_PARAM( mbedtls_md_file( NULL, "", buf ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
#endif
TEST_ASSERT( mbedtls_md_hmac_starts( NULL, buf, 1 )
== MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_ASSERT( mbedtls_md_hmac_starts( &ctx, buf, 1 )
== MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_INVALID_PARAM( mbedtls_md_hmac_starts( NULL, buf, 1 ) );
TEST_INVALID_PARAM( mbedtls_md_hmac_starts( &ctx, buf, 1 ) );
TEST_ASSERT( mbedtls_md_hmac_update( NULL, buf, 1 )
== MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_ASSERT( mbedtls_md_hmac_update( &ctx, buf, 1 )
== MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_INVALID_PARAM( mbedtls_md_hmac_update( NULL, buf, 1 ) );
TEST_INVALID_PARAM( mbedtls_md_hmac_update( &ctx, buf, 1 ) );
TEST_ASSERT( mbedtls_md_hmac_finish( NULL, buf )
== MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_ASSERT( mbedtls_md_hmac_finish( &ctx, buf )
== MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_INVALID_PARAM( mbedtls_md_hmac_finish( NULL, buf ) );
TEST_INVALID_PARAM( mbedtls_md_hmac_finish( &ctx, buf ) );
TEST_ASSERT( mbedtls_md_hmac_reset( NULL ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_ASSERT( mbedtls_md_hmac_reset( &ctx ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_INVALID_PARAM( mbedtls_md_hmac_reset( NULL ) );
TEST_INVALID_PARAM( mbedtls_md_hmac_reset( &ctx ) );
TEST_ASSERT( mbedtls_md_hmac( NULL, buf, 1, buf, 1, buf )
== MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_INVALID_PARAM( mbedtls_md_hmac( NULL, buf, 1, buf, 1, buf ) );
TEST_ASSERT( mbedtls_md_process( NULL, buf ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_ASSERT( mbedtls_md_process( &ctx, buf ) == MBEDTLS_ERR_MD_BAD_INPUT_DATA );
TEST_INVALID_PARAM( mbedtls_md_process( NULL, buf ) );
TEST_INVALID_PARAM( mbedtls_md_process( &ctx, buf ) );
/* Ok, this is not NULL arg but NULL return... */
TEST_ASSERT( mbedtls_md_info_from_type( MBEDTLS_MD_NONE ) == NULL );