mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 03:25:38 +01:00
MD: Implement config dep'n inlining of mbedtls_md_finish()
This commit is contained in:
parent
fdef5ac13b
commit
993691d9ba
@ -352,7 +352,8 @@ MBEDTLS_MD_INLINABLE_API int mbedtls_md_update( mbedtls_md_context_t *ctx,
|
||||
* \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification
|
||||
* failure.
|
||||
*/
|
||||
int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output );
|
||||
MBEDTLS_MD_INLINABLE_API int mbedtls_md_finish( mbedtls_md_context_t *ctx,
|
||||
unsigned char *output );
|
||||
|
||||
/**
|
||||
* \brief This function calculates the message-digest of a buffer,
|
||||
@ -372,7 +373,10 @@ int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output );
|
||||
* \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification
|
||||
* failure.
|
||||
*/
|
||||
int mbedtls_md( mbedtls_md_handle_t md_info, const unsigned char *input, size_t ilen,
|
||||
MBEDTLS_MD_INLINABLE_API int mbedtls_md(
|
||||
mbedtls_md_handle_t md_info,
|
||||
const unsigned char *input,
|
||||
size_t ilen,
|
||||
unsigned char *output );
|
||||
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
@ -543,6 +547,34 @@ MBEDTLS_ALWAYS_INLINE static inline int mbedtls_md_update_internal(
|
||||
input, ilen ) );
|
||||
}
|
||||
|
||||
MBEDTLS_ALWAYS_INLINE static inline int mbedtls_md_finish_internal(
|
||||
mbedtls_md_context_t *ctx, unsigned char *output )
|
||||
{
|
||||
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_finish( md_info, ctx->md_ctx,
|
||||
output ) );
|
||||
}
|
||||
|
||||
MBEDTLS_ALWAYS_INLINE static inline int mbedtls_md_internal(
|
||||
mbedtls_md_handle_t md_info,
|
||||
const unsigned char *input,
|
||||
size_t ilen,
|
||||
unsigned char *output )
|
||||
{
|
||||
if( md_info == MBEDTLS_MD_INVALID_HANDLE )
|
||||
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
|
||||
|
||||
return( mbedtls_md_info_digest( md_info, input,
|
||||
ilen, output) );
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_MD_SINGLE_HASH)
|
||||
MBEDTLS_MD_INLINABLE_API int mbedtls_md_starts(
|
||||
mbedtls_md_context_t *ctx )
|
||||
@ -557,6 +589,22 @@ MBEDTLS_MD_INLINABLE_API int mbedtls_md_update(
|
||||
{
|
||||
return( mbedtls_md_update_internal( ctx, input, ilen ) );
|
||||
}
|
||||
|
||||
MBEDTLS_MD_INLINABLE_API int mbedtls_md_finish(
|
||||
mbedtls_md_context_t *ctx, unsigned char *output )
|
||||
{
|
||||
return( mbedtls_md_finish_internal( ctx, output ) );
|
||||
}
|
||||
|
||||
MBEDTLS_MD_INLINABLE_API int mbedtls_md(
|
||||
mbedtls_md_handle_t md_info,
|
||||
const unsigned char *input,
|
||||
size_t ilen,
|
||||
unsigned char *output )
|
||||
{
|
||||
return( mbedtls_md_internal( md_info, input, ilen, output ) );
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_MD_SINGLE_HASH */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
19
library/md.c
19
library/md.c
@ -471,31 +471,18 @@ int mbedtls_md_update( mbedtls_md_context_t *ctx,
|
||||
{
|
||||
return( mbedtls_md_update_internal( ctx, input, ilen ) );
|
||||
}
|
||||
#endif /* !MBEDTLS_MD_SINGLE_HASH */
|
||||
|
||||
int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output )
|
||||
{
|
||||
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_finish( md_info, ctx->md_ctx,
|
||||
output ) );
|
||||
return( mbedtls_md_finish_internal( ctx, output ) );
|
||||
}
|
||||
|
||||
int mbedtls_md( mbedtls_md_handle_t md_info, const unsigned char *input, size_t ilen,
|
||||
unsigned char *output )
|
||||
{
|
||||
if( md_info == MBEDTLS_MD_INVALID_HANDLE )
|
||||
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
|
||||
|
||||
return( mbedtls_md_info_digest( md_info, input,
|
||||
ilen, output) );
|
||||
return( mbedtls_md_internal( md_info, input, ilen, output ) );
|
||||
}
|
||||
#endif /* !MBEDTLS_MD_SINGLE_HASH */
|
||||
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
int mbedtls_md_file( mbedtls_md_handle_t md_info, const char *path, unsigned char *output )
|
||||
|
Loading…
Reference in New Issue
Block a user