34 #if defined(_MSC_VER) && !defined(inline)
35 #define inline _inline
37 #if defined(__ARMCC_VERSION) && !defined(inline)
38 #define inline __inline
42 #define POLARSSL_ERR_MD_FEATURE_UNAVAILABLE -0x5080
43 #define POLARSSL_ERR_MD_BAD_INPUT_DATA -0x5100
44 #define POLARSSL_ERR_MD_ALLOC_FAILED -0x5180
45 #define POLARSSL_ERR_MD_FILE_IO_ERROR -0x5200
64 #if defined(POLARSSL_SHA512_C)
65 #define POLARSSL_MD_MAX_SIZE 64
67 #define POLARSSL_MD_MAX_SIZE 32
85 void (*starts_func)(
void *ctx );
88 void (*update_func)(
void *ctx,
const unsigned char *input,
size_t ilen );
91 void (*finish_func)(
void *ctx,
unsigned char *output );
94 void (*digest_func)(
const unsigned char *input,
size_t ilen,
95 unsigned char *output );
98 int (*file_func)(
const char *path,
unsigned char *output );
101 void (*hmac_starts_func)(
void *ctx,
const unsigned char *key,
size_t keylen );
104 void (*hmac_update_func)(
void *ctx,
const unsigned char *input,
size_t ilen );
107 void (*hmac_finish_func)(
void *ctx,
unsigned char *output);
110 void (*hmac_reset_func)(
void *ctx );
113 void (*hmac_func)(
const unsigned char *key,
size_t keylen,
114 const unsigned char *input,
size_t ilen,
115 unsigned char *output );
118 void * (*ctx_alloc_func)( void );
121 void (*ctx_free_func)(
void *ctx );
124 void (*process_func)(
void *ctx,
const unsigned char *input );
138 #define MD_CONTEXT_T_INIT { \
208 if( md_info == NULL )
211 return md_info->
size;
223 if( md_info == NULL )
226 return md_info->
type;
238 if( md_info == NULL )
241 return md_info->
name;
288 int md(
const md_info_t *md_info,
const unsigned char *input,
size_t ilen,
289 unsigned char *output );
302 int md_file(
const md_info_t *md_info,
const char *path,
unsigned char *output );
362 int md_hmac(
const md_info_t *md_info,
const unsigned char *key,
size_t keylen,
363 const unsigned char *input,
size_t ilen,
364 unsigned char *output );
int md(const md_info_t *md_info, const unsigned char *input, size_t ilen, unsigned char *output)
Output = message_digest( input buffer )
int md_starts(md_context_t *ctx)
Set-up the given context for a new message digest.
int md_file(const md_info_t *md_info, const char *path, unsigned char *output)
Output = message_digest( file contents )
int md_init_ctx(md_context_t *ctx, const md_info_t *md_info)
Initialises and fills the message digest context structure with the appropriate values.
int md_process(md_context_t *ctx, const unsigned char *data)
static unsigned char md_get_size(const md_info_t *md_info)
Returns the size of the message digest output.
const md_info_t * md_info_from_string(const char *md_name)
Returns the message digest information associated with the given digest name.
static md_type_t md_get_type(const md_info_t *md_info)
Returns the type of the message digest output.
const md_info_t * md_info
Information about the associated message digest.
const md_info_t * md_info_from_type(md_type_t md_type)
Returns the message digest information associated with the given digest type.
const int * md_list(void)
Returns the list of digests supported by the generic digest module.
int md_hmac_starts(md_context_t *ctx, const unsigned char *key, size_t keylen)
Generic HMAC context setup.
void * md_ctx
Digest-specific context.
int md_hmac(const 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 )
int md_hmac_reset(md_context_t *ctx)
Generic HMAC context reset.
int md_hmac_update(md_context_t *ctx, const unsigned char *input, size_t ilen)
Generic HMAC process buffer.
const char * name
Name of the message digest.
int size
Output length of the digest function.
static const char * md_get_name(const md_info_t *md_info)
Returns the name of the message digest output.
md_type_t type
Digest identifier.
int md_finish(md_context_t *ctx, unsigned char *output)
Generic message digest final digest.
int md_free_ctx(md_context_t *ctx)
Free the message-specific context of ctx.
Message digest information.
int md_update(md_context_t *ctx, const unsigned char *input, size_t ilen)
Generic message digest process buffer.
int md_hmac_finish(md_context_t *ctx, unsigned char *output)
Generic HMAC final digest.
Generic message digest context.