PolarSSL is now part of ARM Official announcement and rebranded as mbed TLS.

API Documentation (Doxygen generated)

These pages are generated with doxygen directly from the source code!

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: Apache-2.0
11  *
12  * Licensed under the Apache License, Version 2.0 (the "License"); you may
13  * not use this file except in compliance with the License.
14  * You may obtain a copy of the License at
15  *
16  * http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
20  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  *
24  * This file is part of Mbed TLS (https://tls.mbed.org)
25  */
26 
27 #ifndef MBEDTLS_MD_H
28 #define MBEDTLS_MD_H
29 
30 #include <stddef.h>
31 
32 #if !defined(MBEDTLS_CONFIG_FILE)
33 #include "config.h"
34 #else
35 #include MBEDTLS_CONFIG_FILE
36 #endif
37 
38 #define MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE -0x5080
39 #define MBEDTLS_ERR_MD_BAD_INPUT_DATA -0x5100
40 #define MBEDTLS_ERR_MD_ALLOC_FAILED -0x5180
41 #define MBEDTLS_ERR_MD_FILE_IO_ERROR -0x5200
43 /* MBEDTLS_ERR_MD_HW_ACCEL_FAILED is deprecated and should not be used. */
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 mbedtls_md_context_t
86 {
89 
91  void *md_ctx;
92 
94  void *hmac_ctx;
96 
106 const int *mbedtls_md_list( void );
107 
117 const mbedtls_md_info_t *mbedtls_md_info_from_string( const char *md_name );
118 
129 
139 
154 
155 #if ! defined(MBEDTLS_DEPRECATED_REMOVED)
156 #if defined(MBEDTLS_DEPRECATED_WARNING)
157 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
158 #else
159 #define MBEDTLS_DEPRECATED
160 #endif
161 
180 #undef MBEDTLS_DEPRECATED
181 #endif /* MBEDTLS_DEPRECATED_REMOVED */
182 
202 int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac );
203 
224  const mbedtls_md_context_t *src );
225 
235 unsigned char mbedtls_md_get_size( const mbedtls_md_info_t *md_info );
236 
247 
257 const char *mbedtls_md_get_name( const mbedtls_md_info_t *md_info );
258 
273 
290 int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen );
291 
310 int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output );
311 
330 int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen,
331  unsigned char *output );
332 
333 #if defined(MBEDTLS_FS_IO)
334 
351 int mbedtls_md_file( const mbedtls_md_info_t *md_info, const char *path,
352  unsigned char *output );
353 #endif /* MBEDTLS_FS_IO */
354 
373 int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key,
374  size_t keylen );
375 
395 int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *input,
396  size_t ilen );
397 
416 int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output);
417 
434 
457 int mbedtls_md_hmac( const mbedtls_md_info_t *md_info, const unsigned char *key, size_t keylen,
458  const unsigned char *input, size_t ilen,
459  unsigned char *output );
460 
461 /* Internal use */
462 int mbedtls_md_process( mbedtls_md_context_t *ctx, const unsigned char *data );
463 
464 #ifdef __cplusplus
465 }
466 #endif
467 
468 #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...
int mbedtls_md_starts(mbedtls_md_context_t *ctx)
This function starts a message-digest computation.
void * hmac_ctx
The HMAC part of the context.
Definition: md.h:94
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
The digest-specific context.
Definition: md.h:91
Configuration options (set of defines)
The generic message-digest context.
Definition: md.h:85
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...
The SHA-512 message digest.
Definition: md.h:67
The SHA-224 message digest.
Definition: md.h:64
The SHA-1 message digest.
Definition: md.h:63
The MD4 message digest.
Definition: md.h:61
The SHA-256 message digest.
Definition: md.h:65
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:159
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...
struct mbedtls_md_context_t mbedtls_md_context_t
The generic message-digest context.
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...
The MD2 message digest.
Definition: md.h:60
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...
Message digest information.
Definition: md_internal.h:47
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.
The RIPEMD-160 message digest.
Definition: md.h:68
mbedtls_md_type_t
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
Information about the associated message digest.
Definition: md.h:88
The MD5 message digest.
Definition: md.h:62
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.
The SHA-384 message digest.
Definition: md.h:66
None.
Definition: md.h:59