ReactOS  0.4.14-dev-98-gb0d4763
md.h
Go to the documentation of this file.
1 
8 /*
9  * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
10  * SPDX-License-Identifier: GPL-2.0
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License along
23  * with this program; if not, write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  *
26  * This file is part of Mbed TLS (https://tls.mbed.org)
27  */
28 
29 #ifndef MBEDTLS_MD_H
30 #define MBEDTLS_MD_H
31 
32 #include <stddef.h>
33 
34 #if !defined(MBEDTLS_CONFIG_FILE)
35 #include "config.h"
36 #else
37 #include MBEDTLS_CONFIG_FILE
38 #endif
39 
40 #define MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE -0x5080
41 #define MBEDTLS_ERR_MD_BAD_INPUT_DATA -0x5100
42 #define MBEDTLS_ERR_MD_ALLOC_FAILED -0x5180
43 #define MBEDTLS_ERR_MD_FILE_IO_ERROR -0x5200
44 #define MBEDTLS_ERR_MD_HW_ACCEL_FAILED -0x5280
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
58 typedef enum {
70 
71 #if defined(MBEDTLS_SHA512_C)
72 #define MBEDTLS_MD_MAX_SIZE 64 /* longest known is SHA512 */
73 #else
74 #define MBEDTLS_MD_MAX_SIZE 32 /* longest known is SHA256 or less */
75 #endif
76 
81 
85 typedef struct {
88 
90  void *md_ctx;
91 
93  void *hmac_ctx;
95 
105 const int *mbedtls_md_list( void );
106 
116 const mbedtls_md_info_t *mbedtls_md_info_from_string( const char *md_name );
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
160 
178 #undef MBEDTLS_DEPRECATED
179 #endif /* MBEDTLS_DEPRECATED_REMOVED */
180 
199 int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac );
200 
221  const mbedtls_md_context_t *src );
222 
232 unsigned char mbedtls_md_get_size( const mbedtls_md_info_t *md_info );
233 
244 
254 const char *mbedtls_md_get_name( const mbedtls_md_info_t *md_info );
255 
269 
285 int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen );
286 
304 int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output );
305 
323 int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen,
324  unsigned char *output );
325 
326 #if defined(MBEDTLS_FS_IO)
327 
343 int mbedtls_md_file( const mbedtls_md_info_t *md_info, const char *path,
344  unsigned char *output );
345 #endif /* MBEDTLS_FS_IO */
346 
364 int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key,
365  size_t keylen );
366 
385 int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *input,
386  size_t ilen );
387 
405 int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output);
406 
422 
444 int mbedtls_md_hmac( const mbedtls_md_info_t *md_info, const unsigned char *key, size_t keylen,
445  const unsigned char *input, size_t ilen,
446  unsigned char *output );
447 
448 /* Internal use */
449 int mbedtls_md_process( mbedtls_md_context_t *ctx, const unsigned char *data );
450 
451 #ifdef __cplusplus
452 }
453 #endif
454 
455 #endif /* MBEDTLS_MD_H */
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.
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...
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.
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
int mbedtls_md_starts(mbedtls_md_context_t *ctx)
This function starts a message-digest computation.
void * hmac_ctx
Definition: md.h:93
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.
void mbedtls_md_free(mbedtls_md_context_t *ctx)
This function clears the internal structure of ctx and frees any embedded internal structure,...
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_clone(mbedtls_md_context_t *dst, const mbedtls_md_context_t *src)
This function clones the state of an message-digest context.
void * md_ctx
Definition: md.h:90
int mbedtls_md_process(mbedtls_md_context_t *ctx, const unsigned char *data)
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.
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_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.
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_finish(mbedtls_md_context_t *ctx, unsigned char *output)
This function finishes the digest operation, and writes the result to the output buffer.
#define MBEDTLS_DEPRECATED
Definition: md.h:158
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
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.
GLenum src
Definition: glext.h:6340
const int * mbedtls_md_list(void)
This function returns the list of digests supported by the generic digest module.
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.
GLenum GLenum GLenum input
Definition: glext.h:9031
Definition: services.c:325
GLenum GLenum dst
Definition: glext.h:6340
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.
mbedtls_md_type_t
Enumeration of supported message digests.
Definition: md.h:58
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.
const mbedtls_md_info_t * md_info
Definition: md.h:87
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.
Definition: path.c:42