MD: Implement config dep'n inlining of mbedtls_md_update()
This commit is contained in:
parent
527f7c9307
commit
fdef5ac13b
2 changed files with 33 additions and 13 deletions
|
@ -330,7 +330,9 @@ MBEDTLS_MD_INLINABLE_API int mbedtls_md_starts( mbedtls_md_context_t *ctx );
|
||||||
* \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification
|
* \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification
|
||||||
* failure.
|
* failure.
|
||||||
*/
|
*/
|
||||||
int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen );
|
MBEDTLS_MD_INLINABLE_API int mbedtls_md_update( mbedtls_md_context_t *ctx,
|
||||||
|
const unsigned char *input,
|
||||||
|
size_t ilen );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief This function finishes the digest operation,
|
* \brief This function finishes the digest operation,
|
||||||
|
@ -524,12 +526,37 @@ MBEDTLS_ALWAYS_INLINE static inline int mbedtls_md_starts_internal(
|
||||||
return( mbedtls_md_info_starts( md_info, ctx->md_ctx ) );
|
return( mbedtls_md_info_starts( md_info, ctx->md_ctx ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MBEDTLS_ALWAYS_INLINE static inline int mbedtls_md_update_internal(
|
||||||
|
mbedtls_md_context_t *ctx,
|
||||||
|
const unsigned char *input,
|
||||||
|
size_t ilen )
|
||||||
|
{
|
||||||
|
mbedtls_md_handle_t md_info;
|
||||||
|
if( ctx == NULL )
|
||||||
|
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
|
||||||
|
|
||||||
|
md_info = mbedtls_md_get_handle( ctx );
|
||||||
|
if( md_info == MBEDTLS_MD_INVALID_HANDLE )
|
||||||
|
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
|
||||||
|
|
||||||
|
return( mbedtls_md_info_update( md_info, ctx->md_ctx,
|
||||||
|
input, ilen ) );
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(MBEDTLS_MD_SINGLE_HASH)
|
#if defined(MBEDTLS_MD_SINGLE_HASH)
|
||||||
MBEDTLS_MD_INLINABLE_API int mbedtls_md_starts(
|
MBEDTLS_MD_INLINABLE_API int mbedtls_md_starts(
|
||||||
mbedtls_md_context_t *ctx )
|
mbedtls_md_context_t *ctx )
|
||||||
{
|
{
|
||||||
return( mbedtls_md_starts_internal( ctx ) );
|
return( mbedtls_md_starts_internal( ctx ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MBEDTLS_MD_INLINABLE_API int mbedtls_md_update(
|
||||||
|
mbedtls_md_context_t *ctx,
|
||||||
|
const unsigned char *input,
|
||||||
|
size_t ilen )
|
||||||
|
{
|
||||||
|
return( mbedtls_md_update_internal( ctx, input, ilen ) );
|
||||||
|
}
|
||||||
#endif /* MBEDTLS_MD_SINGLE_HASH */
|
#endif /* MBEDTLS_MD_SINGLE_HASH */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
17
library/md.c
17
library/md.c
|
@ -464,21 +464,14 @@ int mbedtls_md_starts( mbedtls_md_context_t *ctx )
|
||||||
{
|
{
|
||||||
return( mbedtls_md_starts_internal( ctx ) );
|
return( mbedtls_md_starts_internal( ctx ) );
|
||||||
}
|
}
|
||||||
#endif /* !MBEDTLS_MD_SINGLE_HASH */
|
|
||||||
|
|
||||||
int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen )
|
int mbedtls_md_update( mbedtls_md_context_t *ctx,
|
||||||
|
const unsigned char *input,
|
||||||
|
size_t ilen )
|
||||||
{
|
{
|
||||||
mbedtls_md_handle_t md_info;
|
return( mbedtls_md_update_internal( ctx, input, ilen ) );
|
||||||
if( ctx == NULL )
|
|
||||||
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
|
|
||||||
|
|
||||||
md_info = mbedtls_md_get_handle( ctx );
|
|
||||||
if( md_info == MBEDTLS_MD_INVALID_HANDLE )
|
|
||||||
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
|
|
||||||
|
|
||||||
return( mbedtls_md_info_update( md_info, ctx->md_ctx,
|
|
||||||
input, ilen ) );
|
|
||||||
}
|
}
|
||||||
|
#endif /* !MBEDTLS_MD_SINGLE_HASH */
|
||||||
|
|
||||||
int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output )
|
int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue