mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-07-07 13:50:35 +00:00
MD: Demonstrate config-dep'n API inlining for mbedtls_md_starts()
This commit is contained in:
parent
7a7b7227cb
commit
527f7c9307
|
@ -82,6 +82,8 @@ typedef enum {
|
||||||
|
|
||||||
#if !defined(MBEDTLS_MD_SINGLE_HASH)
|
#if !defined(MBEDTLS_MD_SINGLE_HASH)
|
||||||
|
|
||||||
|
#define MBEDTLS_MD_INLINABLE_API
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opaque struct defined in md.c.
|
* Opaque struct defined in md.c.
|
||||||
*/
|
*/
|
||||||
|
@ -93,6 +95,8 @@ typedef struct mbedtls_md_info_t const * mbedtls_md_handle_t;
|
||||||
|
|
||||||
#else /* !MBEDTLS_MD_SINGLE_HASH */
|
#else /* !MBEDTLS_MD_SINGLE_HASH */
|
||||||
|
|
||||||
|
#define MBEDTLS_MD_INLINABLE_API MBEDTLS_ALWAYS_INLINE static inline
|
||||||
|
|
||||||
typedef int mbedtls_md_handle_t;
|
typedef int mbedtls_md_handle_t;
|
||||||
#define MBEDTLS_MD_INVALID_HANDLE ( (mbedtls_md_handle_t) 0 )
|
#define MBEDTLS_MD_INVALID_HANDLE ( (mbedtls_md_handle_t) 0 )
|
||||||
#define MBEDTLS_MD_UNIQUE_VALID_HANDLE ( (mbedtls_md_handle_t) 1 )
|
#define MBEDTLS_MD_UNIQUE_VALID_HANDLE ( (mbedtls_md_handle_t) 1 )
|
||||||
|
@ -308,7 +312,7 @@ const char *mbedtls_md_get_name( mbedtls_md_handle_t md_info );
|
||||||
* \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_starts( mbedtls_md_context_t *ctx );
|
MBEDTLS_MD_INLINABLE_API int mbedtls_md_starts( mbedtls_md_context_t *ctx );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief This function feeds an input buffer into an ongoing
|
* \brief This function feeds an input buffer into an ongoing
|
||||||
|
@ -500,6 +504,34 @@ int mbedtls_md_hmac( mbedtls_md_handle_t md_info, const unsigned char *key, size
|
||||||
/* Internal use */
|
/* Internal use */
|
||||||
int mbedtls_md_process( mbedtls_md_context_t *ctx, const unsigned char *data );
|
int mbedtls_md_process( mbedtls_md_context_t *ctx, const unsigned char *data );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Internal wrapper functions for those MD API functions which should be
|
||||||
|
* inlined in some but not all configurations. The actual MD API will be
|
||||||
|
* implemented either here or in md.c, and forward to the wrappers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
MBEDTLS_ALWAYS_INLINE static inline int mbedtls_md_starts_internal(
|
||||||
|
mbedtls_md_context_t *ctx )
|
||||||
|
{
|
||||||
|
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_starts( md_info, ctx->md_ctx ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_MD_SINGLE_HASH)
|
||||||
|
MBEDTLS_MD_INLINABLE_API int mbedtls_md_starts(
|
||||||
|
mbedtls_md_context_t *ctx )
|
||||||
|
{
|
||||||
|
return( mbedtls_md_starts_internal( ctx ) );
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_MD_SINGLE_HASH */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
12
library/md.c
12
library/md.c
|
@ -459,18 +459,12 @@ int mbedtls_md_setup( mbedtls_md_context_t *ctx, mbedtls_md_handle_t md_info, in
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(MBEDTLS_MD_SINGLE_HASH)
|
||||||
int mbedtls_md_starts( mbedtls_md_context_t *ctx )
|
int mbedtls_md_starts( mbedtls_md_context_t *ctx )
|
||||||
{
|
{
|
||||||
mbedtls_md_handle_t md_info;
|
return( mbedtls_md_starts_internal( ctx ) );
|
||||||
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_starts( md_info, ctx->md_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 )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue