mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-11-23 00:02:39 +03:00
Merge branch 'development' into sha3
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* \file md.h
|
||||
*
|
||||
* \brief This file contains the generic message-digest wrapper.
|
||||
@@ -69,8 +69,14 @@ typedef enum {
|
||||
|
||||
#if defined(MBEDTLS_SHA512_C) || defined(MBEDTLS_SHA3_C)
|
||||
#define MBEDTLS_MD_MAX_SIZE 64 /* longest known is SHA512 */
|
||||
#elif defined(MBEDTLS_SHA384_C)
|
||||
#define MBEDTLS_MD_MAX_SIZE 48 /* longest known is SHA384 */
|
||||
#elif defined(MBEDTLS_SHA256_C)
|
||||
#define MBEDTLS_MD_MAX_SIZE 32 /* longest known is SHA256 */
|
||||
#elif defined(MBEDTLS_SHA224_C)
|
||||
#define MBEDTLS_MD_MAX_SIZE 28 /* longest known is SHA224 */
|
||||
#else
|
||||
#define MBEDTLS_MD_MAX_SIZE 32 /* longest known is SHA256 or less */
|
||||
#define MBEDTLS_MD_MAX_SIZE 20 /* longest known is SHA1 or RIPE MD-160 */
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA3_C)
|
||||
@@ -96,8 +102,7 @@ typedef struct mbedtls_md_info_t mbedtls_md_info_t;
|
||||
/**
|
||||
* The generic message-digest context.
|
||||
*/
|
||||
typedef struct mbedtls_md_context_t
|
||||
{
|
||||
typedef struct mbedtls_md_context_t {
|
||||
/** Information about the associated message digest. */
|
||||
const mbedtls_md_info_t *MBEDTLS_PRIVATE(md_info);
|
||||
|
||||
@@ -119,7 +124,7 @@ typedef struct mbedtls_md_context_t
|
||||
* message-digest enumeration #mbedtls_md_type_t.
|
||||
* The last entry is 0.
|
||||
*/
|
||||
const int *mbedtls_md_list( void );
|
||||
const int *mbedtls_md_list(void);
|
||||
|
||||
/**
|
||||
* \brief This function returns the message-digest information
|
||||
@@ -130,7 +135,7 @@ const int *mbedtls_md_list( void );
|
||||
* \return The message-digest information associated with \p md_name.
|
||||
* \return NULL if the associated message-digest information is not found.
|
||||
*/
|
||||
const mbedtls_md_info_t *mbedtls_md_info_from_string( const char *md_name );
|
||||
const mbedtls_md_info_t *mbedtls_md_info_from_string(const char *md_name);
|
||||
|
||||
/**
|
||||
* \brief This function returns the message-digest information
|
||||
@@ -141,7 +146,7 @@ const mbedtls_md_info_t *mbedtls_md_info_from_string( const char *md_name );
|
||||
* \return The message-digest information associated with \p md_type.
|
||||
* \return NULL if the associated message-digest information is not found.
|
||||
*/
|
||||
const mbedtls_md_info_t *mbedtls_md_info_from_type( mbedtls_md_type_t md_type );
|
||||
const mbedtls_md_info_t *mbedtls_md_info_from_type(mbedtls_md_type_t md_type);
|
||||
|
||||
/**
|
||||
* \brief This function returns the message-digest information
|
||||
@@ -154,7 +159,7 @@ const mbedtls_md_info_t *mbedtls_md_info_from_type( mbedtls_md_type_t md_type );
|
||||
* \return \c NULL if \p ctx is \c NULL.
|
||||
*/
|
||||
const mbedtls_md_info_t *mbedtls_md_info_from_ctx(
|
||||
const mbedtls_md_context_t *ctx );
|
||||
const mbedtls_md_context_t *ctx);
|
||||
|
||||
/**
|
||||
* \brief This function initializes a message-digest context without
|
||||
@@ -164,7 +169,7 @@ const mbedtls_md_info_t *mbedtls_md_info_from_ctx(
|
||||
* context for mbedtls_md_setup() for binding it to a
|
||||
* message-digest algorithm.
|
||||
*/
|
||||
void mbedtls_md_init( mbedtls_md_context_t *ctx );
|
||||
void mbedtls_md_init(mbedtls_md_context_t *ctx);
|
||||
|
||||
/**
|
||||
* \brief This function clears the internal structure of \p ctx and
|
||||
@@ -179,7 +184,7 @@ void mbedtls_md_init( mbedtls_md_context_t *ctx );
|
||||
* You must not call this function if you have not called
|
||||
* mbedtls_md_init().
|
||||
*/
|
||||
void mbedtls_md_free( mbedtls_md_context_t *ctx );
|
||||
void mbedtls_md_free(mbedtls_md_context_t *ctx);
|
||||
|
||||
|
||||
/**
|
||||
@@ -202,7 +207,7 @@ void mbedtls_md_free( mbedtls_md_context_t *ctx );
|
||||
* \return #MBEDTLS_ERR_MD_ALLOC_FAILED on memory-allocation failure.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_TYPICAL
|
||||
int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac );
|
||||
int mbedtls_md_setup(mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac);
|
||||
|
||||
/**
|
||||
* \brief This function clones the state of a message-digest
|
||||
@@ -224,8 +229,8 @@ int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_inf
|
||||
* \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification failure.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_TYPICAL
|
||||
int mbedtls_md_clone( mbedtls_md_context_t *dst,
|
||||
const mbedtls_md_context_t *src );
|
||||
int mbedtls_md_clone(mbedtls_md_context_t *dst,
|
||||
const mbedtls_md_context_t *src);
|
||||
|
||||
/**
|
||||
* \brief This function extracts the message-digest size from the
|
||||
@@ -236,7 +241,7 @@ int mbedtls_md_clone( mbedtls_md_context_t *dst,
|
||||
*
|
||||
* \return The size of the message-digest output in Bytes.
|
||||
*/
|
||||
unsigned char mbedtls_md_get_size( const mbedtls_md_info_t *md_info );
|
||||
unsigned char mbedtls_md_get_size(const mbedtls_md_info_t *md_info);
|
||||
|
||||
/**
|
||||
* \brief This function extracts the message-digest type from the
|
||||
@@ -247,7 +252,7 @@ unsigned char mbedtls_md_get_size( const mbedtls_md_info_t *md_info );
|
||||
*
|
||||
* \return The type of the message digest.
|
||||
*/
|
||||
mbedtls_md_type_t mbedtls_md_get_type( const mbedtls_md_info_t *md_info );
|
||||
mbedtls_md_type_t mbedtls_md_get_type(const mbedtls_md_info_t *md_info);
|
||||
|
||||
/**
|
||||
* \brief This function extracts the message-digest name from the
|
||||
@@ -258,7 +263,7 @@ mbedtls_md_type_t mbedtls_md_get_type( const mbedtls_md_info_t *md_info );
|
||||
*
|
||||
* \return The name of the message digest.
|
||||
*/
|
||||
const char *mbedtls_md_get_name( const mbedtls_md_info_t *md_info );
|
||||
const char *mbedtls_md_get_name(const mbedtls_md_info_t *md_info);
|
||||
|
||||
/**
|
||||
* \brief This function starts a message-digest computation.
|
||||
@@ -274,7 +279,7 @@ const char *mbedtls_md_get_name( const mbedtls_md_info_t *md_info );
|
||||
* failure.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_TYPICAL
|
||||
int mbedtls_md_starts( mbedtls_md_context_t *ctx );
|
||||
int mbedtls_md_starts(mbedtls_md_context_t *ctx);
|
||||
|
||||
/**
|
||||
* \brief This function feeds an input buffer into an ongoing
|
||||
@@ -293,7 +298,7 @@ int mbedtls_md_starts( mbedtls_md_context_t *ctx );
|
||||
* failure.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_TYPICAL
|
||||
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);
|
||||
|
||||
/**
|
||||
* \brief This function finishes the digest operation,
|
||||
@@ -314,7 +319,7 @@ int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, si
|
||||
* failure.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_TYPICAL
|
||||
int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output );
|
||||
int mbedtls_md_finish(mbedtls_md_context_t *ctx, unsigned char *output);
|
||||
|
||||
/**
|
||||
* \brief This function calculates the message-digest of a buffer,
|
||||
@@ -335,8 +340,8 @@ int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output );
|
||||
* failure.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_TYPICAL
|
||||
int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen,
|
||||
unsigned char *output );
|
||||
int mbedtls_md(const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen,
|
||||
unsigned char *output);
|
||||
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
/**
|
||||
@@ -357,8 +362,8 @@ int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, si
|
||||
* \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA if \p md_info was NULL.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_TYPICAL
|
||||
int mbedtls_md_file( const mbedtls_md_info_t *md_info, const char *path,
|
||||
unsigned char *output );
|
||||
int mbedtls_md_file(const mbedtls_md_info_t *md_info, const char *path,
|
||||
unsigned char *output);
|
||||
#endif /* MBEDTLS_FS_IO */
|
||||
|
||||
/**
|
||||
@@ -380,8 +385,8 @@ int mbedtls_md_file( const mbedtls_md_info_t *md_info, const char *path,
|
||||
* failure.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_TYPICAL
|
||||
int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key,
|
||||
size_t keylen );
|
||||
int mbedtls_md_hmac_starts(mbedtls_md_context_t *ctx, const unsigned char *key,
|
||||
size_t keylen);
|
||||
|
||||
/**
|
||||
* \brief This function feeds an input buffer into an ongoing HMAC
|
||||
@@ -403,8 +408,8 @@ int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key,
|
||||
* failure.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_TYPICAL
|
||||
int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *input,
|
||||
size_t ilen );
|
||||
int mbedtls_md_hmac_update(mbedtls_md_context_t *ctx, const unsigned char *input,
|
||||
size_t ilen);
|
||||
|
||||
/**
|
||||
* \brief This function finishes the HMAC operation, and writes
|
||||
@@ -425,7 +430,7 @@ int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *inpu
|
||||
* failure.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_TYPICAL
|
||||
int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output);
|
||||
int mbedtls_md_hmac_finish(mbedtls_md_context_t *ctx, unsigned char *output);
|
||||
|
||||
/**
|
||||
* \brief This function prepares to authenticate a new message with
|
||||
@@ -443,7 +448,7 @@ int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output);
|
||||
* failure.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_TYPICAL
|
||||
int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx );
|
||||
int mbedtls_md_hmac_reset(mbedtls_md_context_t *ctx);
|
||||
|
||||
/**
|
||||
* \brief This function calculates the full generic HMAC
|
||||
@@ -468,13 +473,13 @@ int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx );
|
||||
* failure.
|
||||
*/
|
||||
MBEDTLS_CHECK_RETURN_TYPICAL
|
||||
int mbedtls_md_hmac( const mbedtls_md_info_t *md_info, const unsigned char *key, size_t keylen,
|
||||
const unsigned char *input, size_t ilen,
|
||||
unsigned char *output );
|
||||
int mbedtls_md_hmac(const mbedtls_md_info_t *md_info, const unsigned char *key, size_t keylen,
|
||||
const unsigned char *input, size_t ilen,
|
||||
unsigned char *output);
|
||||
|
||||
/* Internal use */
|
||||
MBEDTLS_CHECK_RETURN_TYPICAL
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user