Mbed TLS v2.28.8
Loading...
Searching...
No Matches
md.h
Go to the documentation of this file.
1
8/*
9 * Copyright The Mbed TLS Contributors
10 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
11 */
12
13#ifndef MBEDTLS_MD_H
14#define MBEDTLS_MD_H
15
16#include <stddef.h>
17
18#if !defined(MBEDTLS_CONFIG_FILE)
19#include "mbedtls/config.h"
20#else
21#include MBEDTLS_CONFIG_FILE
22#endif
24
26#define MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE -0x5080
28#define MBEDTLS_ERR_MD_BAD_INPUT_DATA -0x5100
30#define MBEDTLS_ERR_MD_ALLOC_FAILED -0x5180
32#define MBEDTLS_ERR_MD_FILE_IO_ERROR -0x5200
33
34/* MBEDTLS_ERR_MD_HW_ACCEL_FAILED is deprecated and should not be used. */
36#define MBEDTLS_ERR_MD_HW_ACCEL_FAILED -0x5280
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
62
63#if defined(MBEDTLS_SHA512_C)
64#define MBEDTLS_MD_MAX_SIZE 64 /* longest known is SHA512 */
65#else
66#define MBEDTLS_MD_MAX_SIZE 32 /* longest known is SHA256 or less */
67#endif
68
69#if defined(MBEDTLS_SHA512_C)
70#define MBEDTLS_MD_MAX_BLOCK_SIZE 128
71#else
72#define MBEDTLS_MD_MAX_BLOCK_SIZE 64
73#endif
74
79
93
105const int *mbedtls_md_list(void);
106
117
128
138
153
154#if !defined(MBEDTLS_DEPRECATED_REMOVED)
155#if defined(MBEDTLS_DEPRECATED_WARNING)
156#define MBEDTLS_DEPRECATED __attribute__((deprecated))
157#else
158#define MBEDTLS_DEPRECATED
159#endif
180#undef MBEDTLS_DEPRECATED
181#endif /* MBEDTLS_DEPRECATED_REMOVED */
182
203int mbedtls_md_setup(mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac);
204
226 const mbedtls_md_context_t *src);
227
237unsigned char mbedtls_md_get_size(const mbedtls_md_info_t *md_info);
238
249
259const char *mbedtls_md_get_name(const mbedtls_md_info_t *md_info);
260
276
294int mbedtls_md_update(mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen);
295
315int mbedtls_md_finish(mbedtls_md_context_t *ctx, unsigned char *output);
316
336int mbedtls_md(const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen,
337 unsigned char *output);
338
339#if defined(MBEDTLS_FS_IO)
358int mbedtls_md_file(const mbedtls_md_info_t *md_info, const char *path,
359 unsigned char *output);
360#endif /* MBEDTLS_FS_IO */
361
381int mbedtls_md_hmac_starts(mbedtls_md_context_t *ctx, const unsigned char *key,
382 size_t keylen);
383
404int mbedtls_md_hmac_update(mbedtls_md_context_t *ctx, const unsigned char *input,
405 size_t ilen);
406
426int mbedtls_md_hmac_finish(mbedtls_md_context_t *ctx, unsigned char *output);
427
445
469int mbedtls_md_hmac(const mbedtls_md_info_t *md_info, const unsigned char *key, size_t keylen,
470 const unsigned char *input, size_t ilen,
471 unsigned char *output);
472
473/* Internal use */
475int mbedtls_md_process(mbedtls_md_context_t *ctx, const unsigned char *data);
476
477#ifdef __cplusplus
478}
479#endif
480
481#endif /* MBEDTLS_MD_H */
Configuration options (set of defines)
const int * mbedtls_md_list(void)
This function returns the list of digests supported by the generic digest module.
int mbedtls_md_setup(mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac)
This function selects the message digest algorithm to use, and allocates internal structures.
mbedtls_md_type_t
Supported message digests.
Definition md.h:50
@ MBEDTLS_MD_SHA512
Definition md.h:59
@ MBEDTLS_MD_MD5
Definition md.h:54
@ MBEDTLS_MD_RIPEMD160
Definition md.h:60
@ MBEDTLS_MD_SHA384
Definition md.h:58
@ MBEDTLS_MD_NONE
Definition md.h:51
@ MBEDTLS_MD_SHA256
Definition md.h:57
@ MBEDTLS_MD_SHA224
Definition md.h:56
@ MBEDTLS_MD_SHA1
Definition md.h:55
@ MBEDTLS_MD_MD4
Definition md.h:53
@ MBEDTLS_MD_MD2
Definition md.h:52
int mbedtls_md_starts(mbedtls_md_context_t *ctx)
This function starts a message-digest computation.
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)
This function calculates the full generic HMAC on the input buffer with the provided key.
int mbedtls_md(const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen, unsigned char *output)
This function calculates the message-digest of a buffer, with respect to a configurable message-diges...
int mbedtls_md_hmac_reset(mbedtls_md_context_t *ctx)
This function prepares to authenticate a new message with the same key as the previous HMAC operation...
const char * mbedtls_md_get_name(const mbedtls_md_info_t *md_info)
This function extracts the message-digest name from the message-digest information structure.
int mbedtls_md_init_ctx(mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info) MBEDTLS_DEPRECATED
This function selects the message digest algorithm to use, and allocates internal structures.
struct mbedtls_md_info_t mbedtls_md_info_t
Definition md.h:78
int mbedtls_md_clone(mbedtls_md_context_t *dst, const mbedtls_md_context_t *src)
This function clones the state of a message-digest context.
struct mbedtls_md_context_t mbedtls_md_context_t
mbedtls_md_type_t mbedtls_md_get_type(const mbedtls_md_info_t *md_info)
This function extracts the message-digest type from the message-digest information structure.
int mbedtls_md_hmac_finish(mbedtls_md_context_t *ctx, unsigned char *output)
This function finishes the HMAC operation, and writes the result to the output buffer.
int mbedtls_md_update(mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen)
This function feeds an input buffer into an ongoing message-digest computation.
int mbedtls_md_hmac_update(mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen)
This function feeds an input buffer into an ongoing HMAC computation.
int mbedtls_md_hmac_starts(mbedtls_md_context_t *ctx, const unsigned char *key, size_t keylen)
This function sets the HMAC key and prepares to authenticate a new message.
const mbedtls_md_info_t * mbedtls_md_info_from_type(mbedtls_md_type_t md_type)
This function returns the message-digest information associated with the given digest type.
#define MBEDTLS_DEPRECATED
Definition md.h:158
int mbedtls_md_process(mbedtls_md_context_t *ctx, const unsigned char *data)
int mbedtls_md_file(const mbedtls_md_info_t *md_info, const char *path, unsigned char *output)
This function calculates the message-digest checksum result of the contents of the provided file.
void mbedtls_md_init(mbedtls_md_context_t *ctx)
This function initializes a message-digest context without binding it to a particular message-digest ...
int mbedtls_md_finish(mbedtls_md_context_t *ctx, unsigned char *output)
This function finishes the digest operation, and writes the result to the output buffer.
const mbedtls_md_info_t * mbedtls_md_info_from_string(const char *md_name)
This function returns the message-digest information associated with the given digest name.
unsigned char mbedtls_md_get_size(const mbedtls_md_info_t *md_info)
This function extracts the message-digest size from the message-digest information structure.
void mbedtls_md_free(mbedtls_md_context_t *ctx)
This function clears the internal structure of ctx and frees any embedded internal structure,...
Common and shared functions used by multiple modules in the Mbed TLS library.
#define MBEDTLS_CHECK_RETURN_TYPICAL
const mbedtls_md_info_t * md_info
Definition md.h:85
void * hmac_ctx
Definition md.h:91
void * md_ctx
Definition md.h:88