md.h
Go to the documentation of this file.
#ifndef MBEDTLS_MD_H
#define MBEDTLS_MD_H
#include <stddef.h>
#define MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE -0x5080
#define MBEDTLS_ERR_MD_BAD_INPUT_DATA -0x5100
#define MBEDTLS_ERR_MD_ALLOC_FAILED -0x5180
#define MBEDTLS_ERR_MD_FILE_IO_ERROR -0x5200
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
MBEDTLS_MD_NONE=0,
MBEDTLS_MD_MD2,
MBEDTLS_MD_MD4,
MBEDTLS_MD_MD5,
MBEDTLS_MD_SHA1,
MBEDTLS_MD_SHA224,
MBEDTLS_MD_SHA256,
MBEDTLS_MD_SHA384,
MBEDTLS_MD_SHA512,
MBEDTLS_MD_RIPEMD160,
} mbedtls_md_type_t;
#if defined(MBEDTLS_SHA512_C)
#define MBEDTLS_MD_MAX_SIZE 64 /* longest known is SHA512 */
#else
#define MBEDTLS_MD_MAX_SIZE 32 /* longest known is SHA256 or less */
#endif
typedef struct mbedtls_md_info_t mbedtls_md_info_t;
typedef struct {
const mbedtls_md_info_t *md_info;
void *md_ctx;
void *hmac_ctx;
} mbedtls_md_context_t;
const int *mbedtls_md_list( void );
const mbedtls_md_info_t *mbedtls_md_info_from_string( const char *md_name );
const mbedtls_md_info_t *mbedtls_md_info_from_type( mbedtls_md_type_t md_type );
void mbedtls_md_init( mbedtls_md_context_t *ctx );
void mbedtls_md_free( mbedtls_md_context_t *ctx );
#if ! defined(MBEDTLS_DEPRECATED_REMOVED)
#if defined(MBEDTLS_DEPRECATED_WARNING)
#define MBEDTLS_DEPRECATED __attribute__((deprecated))
#else
#define MBEDTLS_DEPRECATED
#endif
int mbedtls_md_init_ctx( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info ) MBEDTLS_DEPRECATED;
#undef MBEDTLS_DEPRECATED
#endif /* MBEDTLS_DEPRECATED_REMOVED */
int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac );
int mbedtls_md_clone( mbedtls_md_context_t *dst,
const mbedtls_md_context_t *src );
unsigned char mbedtls_md_get_size( const mbedtls_md_info_t *md_info );
mbedtls_md_type_t mbedtls_md_get_type( const mbedtls_md_info_t *md_info );
const char *mbedtls_md_get_name( const mbedtls_md_info_t *md_info );
int mbedtls_md_starts( mbedtls_md_context_t *ctx );
int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen );
int mbedtls_md_finish( mbedtls_md_context_t *ctx, 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)
int mbedtls_md_file( const mbedtls_md_info_t *md_info, const char *path,
unsigned char *output );
#endif /* MBEDTLS_FS_IO */
int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key,
size_t keylen );
int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *input,
size_t ilen );
int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output);
int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx );
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 */
int mbedtls_md_process( mbedtls_md_context_t *ctx, const unsigned char *data );
#ifdef __cplusplus
}
#endif
#endif /* MBEDTLS_MD_H */
mbedtls_md_init_ctx
int mbedtls_md_init_ctx(mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info) MBEDTLS_DEPRECATED
Select MD to use and allocate internal structures.
mbedtls_md_hmac_reset
int mbedtls_md_hmac_reset(mbedtls_md_context_t *ctx)
Prepare to authenticate a new message with the same key.
mbedtls_md_get_type
mbedtls_md_type_t mbedtls_md_get_type(const mbedtls_md_info_t *md_info)
Returns the type of the message digest output.
mbedtls_md_starts
int mbedtls_md_starts(mbedtls_md_context_t *ctx)
Prepare the context to digest a new message.
mbedtls_md_context_t::hmac_ctx
void * hmac_ctx
HMAC part of the context.
Definition: md.h:74
mbedtls_md_hmac_update
int mbedtls_md_hmac_update(mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen)
Generic HMAC process buffer.
mbedtls_md_free
void mbedtls_md_free(mbedtls_md_context_t *ctx)
Free and clear the internal structures of ctx.
mbedtls_md_init
void mbedtls_md_init(mbedtls_md_context_t *ctx)
Initialize a md_context (as NONE) This should always be called first.
mbedtls_md_clone
int mbedtls_md_clone(mbedtls_md_context_t *dst, const mbedtls_md_context_t *src)
Clone the state of an MD context.
mbedtls_md_context_t::md_ctx
void * md_ctx
Digest-specific context.
Definition: md.h:71
mbedtls_md_context_t
Generic message digest context.
Definition: md.h:66
mbedtls_md_process
int mbedtls_md_process(mbedtls_md_context_t *ctx, const unsigned char *data)
mbedtls_md_get_size
unsigned char mbedtls_md_get_size(const mbedtls_md_info_t *md_info)
Returns the size of the message digest output.
mbedtls_md_hmac_finish
int mbedtls_md_hmac_finish(mbedtls_md_context_t *ctx, unsigned char *output)
Output HMAC.
mbedtls_md_setup
int mbedtls_md_setup(mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac)
Select MD to use and allocate internal structures.
MBEDTLS_MD_SHA512
Definition: md.h:48
MBEDTLS_MD_SHA224
Definition: md.h:45
MBEDTLS_MD_SHA1
Definition: md.h:44
MBEDTLS_MD_MD4
Definition: md.h:42
MBEDTLS_MD_SHA256
Definition: md.h:46
mbedtls_md_hmac
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)
Output = Generic_HMAC( hmac key, input buffer )
mbedtls_md
int mbedtls_md(const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen, unsigned char *output)
Output = message_digest( input buffer )
mbedtls_md_finish
int mbedtls_md_finish(mbedtls_md_context_t *ctx, unsigned char *output)
Generic message digest final digest Called after mbedtls_md_update().
MBEDTLS_DEPRECATED
#define MBEDTLS_DEPRECATED
Definition: md.h:125
mbedtls_md_get_name
const char * mbedtls_md_get_name(const mbedtls_md_info_t *md_info)
Returns the name of the message digest output.
mbedtls_md_list
const int * mbedtls_md_list(void)
Returns the list of digests supported by the generic digest module.
mbedtls_md_info_from_type
const mbedtls_md_info_t * mbedtls_md_info_from_type(mbedtls_md_type_t md_type)
Returns the message digest information associated with the given digest type.
MBEDTLS_MD_MD2
Definition: md.h:41
mbedtls_md_info_t
Message digest information.
Definition: md_internal.h:46
mbedtls_md_hmac_starts
int mbedtls_md_hmac_starts(mbedtls_md_context_t *ctx, const unsigned char *key, size_t keylen)
Set HMAC key and prepare to authenticate a new message.
MBEDTLS_MD_RIPEMD160
Definition: md.h:49
mbedtls_md_type_t
mbedtls_md_type_t
Definition: md.h:39
mbedtls_md_info_from_string
const mbedtls_md_info_t * mbedtls_md_info_from_string(const char *md_name)
Returns the message digest information associated with the given digest name.
mbedtls_md_context_t::md_info
const mbedtls_md_info_t * md_info
Information about the associated message digest.
Definition: md.h:68
MBEDTLS_MD_MD5
Definition: md.h:43
mbedtls_md_update
int mbedtls_md_update(mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen)
Generic message digest process buffer Called between mbedtls_md_starts() and mbedtls_md_finish().
MBEDTLS_MD_SHA384
Definition: md.h:47
MBEDTLS_MD_NONE
Definition: md.h:40