mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-03-25 19:45:16 +00: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
|
* \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification
|
||||||
* failure.
|
* 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,
|
* \brief This function calculates the message-digest of a buffer,
|
||||||
|
@ -372,8 +373,11 @@ int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output );
|
||||||
* \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( mbedtls_md_handle_t md_info, const unsigned char *input, size_t ilen,
|
MBEDTLS_MD_INLINABLE_API int mbedtls_md(
|
||||||
unsigned char *output );
|
mbedtls_md_handle_t md_info,
|
||||||
|
const unsigned char *input,
|
||||||
|
size_t ilen,
|
||||||
|
unsigned char *output );
|
||||||
|
|
||||||
#if defined(MBEDTLS_FS_IO)
|
#if defined(MBEDTLS_FS_IO)
|
||||||
/**
|
/**
|
||||||
|
@ -543,6 +547,34 @@ MBEDTLS_ALWAYS_INLINE static inline int mbedtls_md_update_internal(
|
||||||
input, ilen ) );
|
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)
|
#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 )
|
||||||
|
@ -557,6 +589,22 @@ MBEDTLS_MD_INLINABLE_API int mbedtls_md_update(
|
||||||
{
|
{
|
||||||
return( mbedtls_md_update_internal( ctx, input, ilen ) );
|
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 */
|
#endif /* MBEDTLS_MD_SINGLE_HASH */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#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 ) );
|
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 )
|
int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output )
|
||||||
{
|
{
|
||||||
mbedtls_md_handle_t md_info;
|
return( mbedtls_md_finish_internal( ctx, output ) );
|
||||||
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 ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_md( mbedtls_md_handle_t md_info, const unsigned char *input, size_t ilen,
|
int mbedtls_md( mbedtls_md_handle_t md_info, const unsigned char *input, size_t ilen,
|
||||||
unsigned char *output )
|
unsigned char *output )
|
||||||
{
|
{
|
||||||
if( md_info == MBEDTLS_MD_INVALID_HANDLE )
|
return( mbedtls_md_internal( md_info, input, ilen, output ) );
|
||||||
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
|
|
||||||
|
|
||||||
return( mbedtls_md_info_digest( md_info, input,
|
|
||||||
ilen, output) );
|
|
||||||
}
|
}
|
||||||
|
#endif /* !MBEDTLS_MD_SINGLE_HASH */
|
||||||
|
|
||||||
#if defined(MBEDTLS_FS_IO)
|
#if defined(MBEDTLS_FS_IO)
|
||||||
int mbedtls_md_file( mbedtls_md_handle_t md_info, const char *path, unsigned char *output )
|
int mbedtls_md_file( mbedtls_md_handle_t md_info, const char *path, unsigned char *output )
|
||||||
|
|
Loading…
Reference in a new issue