2011-01-06 15:20:01 +01:00
|
|
|
/**
|
2015-04-08 12:49:31 +02:00
|
|
|
* \file mbedtls_md.h
|
2014-05-01 13:03:14 +02:00
|
|
|
*
|
2011-01-06 15:20:01 +01:00
|
|
|
* \brief Generic message digest wrapper
|
|
|
|
*
|
|
|
|
* \author Adriaan de Jong <dejong@fox-it.com>
|
|
|
|
*
|
2015-03-24 12:13:30 +01:00
|
|
|
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
2011-01-06 15:20:01 +01:00
|
|
|
*
|
2015-03-06 14:17:10 +01:00
|
|
|
* This file is part of mbed TLS (https://tls.mbed.org)
|
2011-01-06 15:20:01 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
#ifndef MBEDTLS_MD_H
|
|
|
|
#define MBEDTLS_MD_H
|
2011-01-06 15:20:01 +01:00
|
|
|
|
2015-02-06 14:43:58 +01:00
|
|
|
#include <stddef.h>
|
2011-04-24 10:57:21 +02:00
|
|
|
|
2011-07-27 18:28:54 +02:00
|
|
|
#if defined(_MSC_VER) && !defined(inline)
|
2011-04-18 05:47:52 +02:00
|
|
|
#define inline _inline
|
2011-06-21 09:48:07 +02:00
|
|
|
#else
|
2011-07-27 18:28:54 +02:00
|
|
|
#if defined(__ARMCC_VERSION) && !defined(inline)
|
2011-06-21 09:48:07 +02:00
|
|
|
#define inline __inline
|
2011-06-21 15:36:18 +02:00
|
|
|
#endif /* __ARMCC_VERSION */
|
2011-06-21 09:48:07 +02:00
|
|
|
#endif /*_MSC_VER */
|
2011-04-18 05:47:52 +02:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#define MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE -0x5080 /**< The selected feature is not available. */
|
|
|
|
#define MBEDTLS_ERR_MD_BAD_INPUT_DATA -0x5100 /**< Bad input parameters to function. */
|
|
|
|
#define MBEDTLS_ERR_MD_ALLOC_FAILED -0x5180 /**< Failed to allocate memory. */
|
|
|
|
#define MBEDTLS_ERR_MD_FILE_IO_ERROR -0x5200 /**< Opening or reading of file failed. */
|
2011-04-25 17:28:35 +02:00
|
|
|
|
2013-06-27 14:29:21 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2011-01-06 15:20:01 +01:00
|
|
|
typedef enum {
|
2015-04-08 12:49:31 +02:00
|
|
|
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 */
|
2013-09-10 11:10:57 +02:00
|
|
|
#else
|
2015-04-08 12:49:31 +02:00
|
|
|
#define MBEDTLS_MD_MAX_SIZE 32 /* longest known is SHA256 or less */
|
2013-09-10 11:10:57 +02:00
|
|
|
#endif
|
2011-01-06 16:48:19 +01:00
|
|
|
|
2011-01-06 15:20:01 +01:00
|
|
|
/**
|
2015-05-26 11:04:15 +02:00
|
|
|
* Opaque struct defined in md_internal.h
|
2011-01-06 15:20:01 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
typedef struct mbedtls_md_info_t mbedtls_md_info_t;
|
2011-01-06 15:20:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generic message digest context.
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
/** Information about the associated message digest */
|
2015-04-08 12:49:31 +02:00
|
|
|
const mbedtls_md_info_t *md_info;
|
2011-01-06 15:20:01 +01:00
|
|
|
|
|
|
|
/** Digest-specific context */
|
|
|
|
void *md_ctx;
|
2015-03-24 16:48:22 +01:00
|
|
|
|
2015-03-25 11:49:07 +01:00
|
|
|
/** HMAC part of the context */
|
|
|
|
void *hmac_ctx;
|
2015-04-08 12:49:31 +02:00
|
|
|
} mbedtls_md_context_t;
|
2011-01-06 15:20:01 +01:00
|
|
|
|
2011-01-16 22:27:44 +01:00
|
|
|
/**
|
|
|
|
* \brief Returns the list of digests supported by the generic digest module.
|
|
|
|
*
|
|
|
|
* \return a statically allocated array of digests, the last entry
|
|
|
|
* is 0.
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
const int *mbedtls_md_list( void );
|
2011-01-16 22:27:44 +01:00
|
|
|
|
2011-01-06 15:20:01 +01:00
|
|
|
/**
|
|
|
|
* \brief Returns the message digest information associated with the
|
|
|
|
* given digest name.
|
|
|
|
*
|
2011-04-24 10:57:21 +02:00
|
|
|
* \param md_name Name of the digest to search for.
|
2011-01-06 15:20:01 +01:00
|
|
|
*
|
|
|
|
* \return The message digest information associated with md_name or
|
|
|
|
* NULL if not found.
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
const mbedtls_md_info_t *mbedtls_md_info_from_string( const char *md_name );
|
2011-01-06 15:20:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Returns the message digest information associated with the
|
|
|
|
* given digest type.
|
|
|
|
*
|
|
|
|
* \param md_type type of digest to search for.
|
|
|
|
*
|
|
|
|
* \return The message digest information associated with md_type or
|
|
|
|
* NULL if not found.
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
const mbedtls_md_info_t *mbedtls_md_info_from_type( mbedtls_md_type_t md_type );
|
2011-01-06 15:20:01 +01:00
|
|
|
|
2014-07-01 14:53:22 +02:00
|
|
|
/**
|
2015-03-26 12:26:34 +01:00
|
|
|
* \brief Initialize a md_context (as NONE)
|
|
|
|
* This should always be called first.
|
2015-04-08 12:49:31 +02:00
|
|
|
* Prepares the context for mbedtls_md_setup() or mbedtls_md_free().
|
2014-07-01 14:53:22 +02:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
void mbedtls_md_init( mbedtls_md_context_t *ctx );
|
2014-07-01 14:53:22 +02:00
|
|
|
|
|
|
|
/**
|
2015-03-26 12:26:34 +01:00
|
|
|
* \brief Free and clear the internal structures of ctx.
|
2015-04-08 12:49:31 +02:00
|
|
|
* Can be called at any time after mbedtls_md_init().
|
|
|
|
* Mandatory once mbedtls_md_setup() has been called.
|
2014-07-01 14:53:22 +02:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
void mbedtls_md_free( mbedtls_md_context_t *ctx );
|
2014-07-01 14:53:22 +02:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if ! defined(MBEDTLS_DEPRECATED_REMOVED)
|
|
|
|
#if defined(MBEDTLS_DEPRECATED_WARNING)
|
|
|
|
#define MBEDTLS_DEPRECATED __attribute__((deprecated))
|
2015-03-25 16:43:14 +01:00
|
|
|
#else
|
2015-04-08 12:49:31 +02:00
|
|
|
#define MBEDTLS_DEPRECATED
|
2015-03-25 16:43:14 +01:00
|
|
|
#endif
|
|
|
|
/**
|
2015-03-26 12:26:34 +01:00
|
|
|
* \brief Select MD to use and allocate internal structures.
|
2015-04-08 12:49:31 +02:00
|
|
|
* Should be called after mbedtls_md_init() or mbedtls_md_free().
|
|
|
|
* Makes it necessary to call mbedtls_md_free() later.
|
2015-03-25 16:43:14 +01:00
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* \deprecated Superseded by mbedtls_md_setup() in 2.0.0
|
2015-03-25 16:43:14 +01:00
|
|
|
*
|
2015-03-26 12:26:34 +01:00
|
|
|
* \param ctx Context to set up.
|
|
|
|
* \param md_info Message digest to use.
|
2015-03-25 16:43:14 +01:00
|
|
|
*
|
2015-03-26 12:26:34 +01:00
|
|
|
* \returns \c 0 on success,
|
2015-04-08 12:49:31 +02:00
|
|
|
* \c MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure,
|
|
|
|
* \c MBEDTLS_ERR_MD_ALLOC_FAILED memory allocation failure.
|
2015-03-25 16:43:14 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
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 */
|
2015-03-25 16:43:14 +01:00
|
|
|
|
2011-01-20 17:42:01 +01:00
|
|
|
/**
|
2015-03-26 12:26:34 +01:00
|
|
|
* \brief Select MD to use and allocate internal structures.
|
2015-04-08 12:49:31 +02:00
|
|
|
* Should be called after mbedtls_md_init() or mbedtls_md_free().
|
|
|
|
* Makes it necessary to call mbedtls_md_free() later.
|
2015-03-26 12:26:34 +01:00
|
|
|
*
|
|
|
|
* \param ctx Context to set up.
|
|
|
|
* \param md_info Message digest to use.
|
|
|
|
* \param hmac 0 to save some meory is HMAC will not be use,
|
|
|
|
* non-zero is HMAC is going to be used with this context.
|
|
|
|
*
|
|
|
|
* \returns \c 0 on success,
|
2015-04-08 12:49:31 +02:00
|
|
|
* \c MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure,
|
|
|
|
* \c MBEDTLS_ERR_MD_ALLOC_FAILED memory allocation failure.
|
2011-01-20 17:42:01 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac );
|
2011-01-20 17:42:01 +01:00
|
|
|
|
2011-01-06 15:20:01 +01:00
|
|
|
/**
|
|
|
|
* \brief Returns the size of the message digest output.
|
|
|
|
*
|
|
|
|
* \param md_info message digest info
|
|
|
|
*
|
2015-06-18 14:58:58 +02:00
|
|
|
* \return size of the message digest output in bytes.
|
2011-01-06 15:20:01 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
unsigned char mbedtls_md_get_size( const mbedtls_md_info_t *md_info );
|
2011-01-06 15:20:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Returns the type of the message digest output.
|
|
|
|
*
|
|
|
|
* \param md_info message digest info
|
|
|
|
*
|
|
|
|
* \return type of the message digest output.
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_md_type_t mbedtls_md_get_type( const mbedtls_md_info_t *md_info );
|
2011-01-06 15:20:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Returns the name of the message digest output.
|
|
|
|
*
|
|
|
|
* \param md_info message digest info
|
|
|
|
*
|
|
|
|
* \return name of the message digest output.
|
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
const char *mbedtls_md_get_name( const mbedtls_md_info_t *md_info );
|
2011-01-06 15:20:01 +01:00
|
|
|
|
|
|
|
/**
|
2015-03-26 12:26:34 +01:00
|
|
|
* \brief Prepare the context to digest a new message.
|
2015-04-08 12:49:31 +02:00
|
|
|
* Generally called after mbedtls_md_setup() or mbedtls_md_finish().
|
|
|
|
* Followed by mbedtls_md_update().
|
2011-01-06 15:20:01 +01:00
|
|
|
*
|
2015-03-26 12:26:34 +01:00
|
|
|
* \param ctx generic message digest context.
|
2011-01-06 15:20:01 +01:00
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
|
2015-03-26 12:26:34 +01:00
|
|
|
* verification fails.
|
2011-01-06 15:20:01 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_md_starts( mbedtls_md_context_t *ctx );
|
2011-01-06 15:20:01 +01:00
|
|
|
|
|
|
|
/**
|
2015-03-26 12:26:34 +01:00
|
|
|
* \brief Generic message digest process buffer
|
2015-04-08 12:49:31 +02:00
|
|
|
* Called between mbedtls_md_starts() and mbedtls_md_finish().
|
2015-03-26 12:26:34 +01:00
|
|
|
* May be called repeatedly.
|
2011-01-06 15:20:01 +01:00
|
|
|
*
|
2015-03-26 12:26:34 +01:00
|
|
|
* \param ctx Generic message digest context
|
|
|
|
* \param input buffer holding the datal
|
|
|
|
* \param ilen length of the input data
|
2011-01-06 15:20:01 +01:00
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
|
2015-03-26 12:26:34 +01:00
|
|
|
* verification fails.
|
2011-01-06 15:20:01 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen );
|
2011-01-06 15:20:01 +01:00
|
|
|
|
|
|
|
/**
|
2015-03-26 12:26:34 +01:00
|
|
|
* \brief Generic message digest final digest
|
2015-04-08 12:49:31 +02:00
|
|
|
* Called after mbedtls_md_update().
|
|
|
|
* Usually followed by mbedtls_md_free() or mbedtls_md_starts().
|
2011-01-06 15:20:01 +01:00
|
|
|
*
|
2015-03-26 12:26:34 +01:00
|
|
|
* \param ctx Generic message digest context
|
|
|
|
* \param output Generic message digest checksum result
|
2011-01-06 15:20:01 +01:00
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
|
2015-03-26 12:26:34 +01:00
|
|
|
* verification fails.
|
2011-01-06 15:20:01 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output );
|
2011-01-06 15:20:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Output = message_digest( input buffer )
|
|
|
|
*
|
|
|
|
* \param md_info message digest info
|
|
|
|
* \param input buffer holding the data
|
|
|
|
* \param ilen length of the input data
|
|
|
|
* \param output Generic message digest checksum result
|
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
|
2011-06-09 17:55:11 +02:00
|
|
|
* verification fails.
|
2011-01-06 15:20:01 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen,
|
2011-01-06 15:20:01 +01:00
|
|
|
unsigned char *output );
|
|
|
|
|
2015-05-28 14:44:00 +02:00
|
|
|
#if defined(MBEDTLS_FS_IO)
|
2011-01-06 15:20:01 +01:00
|
|
|
/**
|
|
|
|
* \brief Output = message_digest( file contents )
|
|
|
|
*
|
|
|
|
* \param md_info message digest info
|
|
|
|
* \param path input file name
|
|
|
|
* \param output generic message digest checksum result
|
|
|
|
*
|
2015-04-03 16:37:14 +02:00
|
|
|
* \return 0 if successful,
|
2015-04-08 12:49:31 +02:00
|
|
|
* MBEDTLS_ERR_MD_FILE_IO_ERROR if file input failed,
|
|
|
|
* MBEDTLS_ERR_MD_BAD_INPUT_DATA if md_info was NULL.
|
2011-01-06 15:20:01 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_md_file( const mbedtls_md_info_t *md_info, const char *path,
|
2015-05-28 14:44:00 +02:00
|
|
|
unsigned char *output );
|
|
|
|
#endif /* MBEDTLS_FS_IO */
|
2011-01-06 15:20:01 +01:00
|
|
|
|
|
|
|
/**
|
2015-03-26 12:26:34 +01:00
|
|
|
* \brief Set HMAC key and prepare to authenticate a new message.
|
2015-04-08 12:49:31 +02:00
|
|
|
* Usually called after mbedtls_md_setup() or mbedtls_md_hmac_finish().
|
2011-01-06 15:20:01 +01:00
|
|
|
*
|
2015-03-26 12:26:34 +01:00
|
|
|
* \param ctx HMAC context
|
|
|
|
* \param key HMAC secret key
|
2015-06-18 14:58:58 +02:00
|
|
|
* \param keylen length of the HMAC key in bytes
|
2011-01-06 15:20:01 +01:00
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
|
2015-03-26 12:26:34 +01:00
|
|
|
* verification fails.
|
2011-01-06 15:20:01 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key,
|
2014-05-01 14:18:25 +02:00
|
|
|
size_t keylen );
|
2011-01-06 15:20:01 +01:00
|
|
|
|
|
|
|
/**
|
2015-03-26 12:26:34 +01:00
|
|
|
* \brief Generic HMAC process buffer.
|
2015-04-08 12:49:31 +02:00
|
|
|
* Called between mbedtls_md_hmac_starts() or mbedtls_md_hmac_reset()
|
|
|
|
* and mbedtls_md_hmac_finish().
|
2015-03-26 12:26:34 +01:00
|
|
|
* May be called repeatedly.
|
2011-01-06 15:20:01 +01:00
|
|
|
*
|
2015-03-26 12:26:34 +01:00
|
|
|
* \param ctx HMAC context
|
|
|
|
* \param input buffer holding the data
|
|
|
|
* \param ilen length of the input data
|
2011-01-06 15:20:01 +01:00
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
|
2015-03-26 12:26:34 +01:00
|
|
|
* verification fails.
|
2011-01-06 15:20:01 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *input,
|
2014-05-01 14:18:25 +02:00
|
|
|
size_t ilen );
|
2011-01-06 15:20:01 +01:00
|
|
|
|
|
|
|
/**
|
2015-03-26 12:26:34 +01:00
|
|
|
* \brief Output HMAC.
|
2015-04-08 12:49:31 +02:00
|
|
|
* Called after mbedtls_md_hmac_update().
|
|
|
|
* Usually followed my mbedtls_md_hmac_reset(), mbedtls_md_hmac_starts(),
|
|
|
|
* or mbedtls_md_free().
|
2011-01-06 15:20:01 +01:00
|
|
|
*
|
2015-03-26 12:26:34 +01:00
|
|
|
* \param ctx HMAC context
|
|
|
|
* \param output Generic HMAC checksum result
|
2011-01-06 15:20:01 +01:00
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
|
2015-03-26 12:26:34 +01:00
|
|
|
* verification fails.
|
2011-01-06 15:20:01 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output);
|
2011-01-06 15:20:01 +01:00
|
|
|
|
|
|
|
/**
|
2015-03-26 12:26:34 +01:00
|
|
|
* \brief Prepare to authenticate a new message with the same key.
|
2015-04-08 12:49:31 +02:00
|
|
|
* Called after mbedtls_md_hmac_finish() and before mbedtls_md_hmac_update().
|
2011-01-06 15:20:01 +01:00
|
|
|
*
|
2015-03-26 12:26:34 +01:00
|
|
|
* \param ctx HMAC context to be reset
|
2011-01-06 15:20:01 +01:00
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
|
2015-03-26 12:26:34 +01:00
|
|
|
* verification fails.
|
2011-01-06 15:20:01 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx );
|
2011-01-06 15:20:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Output = Generic_HMAC( hmac key, input buffer )
|
|
|
|
*
|
|
|
|
* \param md_info message digest info
|
|
|
|
* \param key HMAC secret key
|
2015-06-18 14:58:58 +02:00
|
|
|
* \param keylen length of the HMAC key in bytes
|
2011-01-06 15:20:01 +01:00
|
|
|
* \param input buffer holding the data
|
|
|
|
* \param ilen length of the input data
|
|
|
|
* \param output Generic HMAC-result
|
|
|
|
*
|
2015-04-08 12:49:31 +02:00
|
|
|
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
|
2011-06-09 17:55:11 +02:00
|
|
|
* verification fails.
|
2011-01-06 15:20:01 +01:00
|
|
|
*/
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_md_hmac( const mbedtls_md_info_t *md_info, const unsigned char *key, size_t keylen,
|
2011-04-24 10:57:21 +02:00
|
|
|
const unsigned char *input, size_t ilen,
|
2011-01-06 15:20:01 +01:00
|
|
|
unsigned char *output );
|
|
|
|
|
2013-03-13 10:26:44 +01:00
|
|
|
/* Internal use */
|
2015-04-08 12:49:31 +02:00
|
|
|
int mbedtls_md_process( mbedtls_md_context_t *ctx, const unsigned char *data );
|
2013-03-13 10:26:44 +01:00
|
|
|
|
2011-01-06 15:20:01 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#endif /* MBEDTLS_MD_H */
|