Example program to test AES-GCM functionality. Used for a workshop
Dependencies:
mbed
« Back to documentation index
md.h File Reference
Generic message digest wrapper.
More...
Go to the source code of this file.
Data Structures
struct md_info_t
Message digest information. More...
struct md_context_t
Generic message digest context. More...
Functions
const int * md_list (void)
Returns the list of digests supported by the generic digest module.
const md_info_t * md_info_from_string (const char *md_name)
Returns the message digest information associated with the given digest name.
const md_info_t * md_info_from_type (md_type_t md_type)
Returns the message digest information associated with the given digest type.
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_free_ctx (md_context_t *ctx)
Free the message-specific context of ctx.
static unsigned char md_get_size (const md_info_t *md_info)
Returns the size of the message digest output.
static md_type_t md_get_type (const md_info_t *md_info)
Returns the type of the message digest output.
static const char * md_get_name (const md_info_t *md_info)
Returns the name of the message digest output.
int md_starts (md_context_t *ctx)
Set-up the given context for a new message digest.
int md_update (md_context_t *ctx, const unsigned char *input, size_t ilen)
Generic message digest process buffer.
int md_finish (md_context_t *ctx, unsigned char *output)
Generic message digest final digest.
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_file (const md_info_t *md_info, const char *path, unsigned char *output)
Output = message_digest( file contents )
int md_hmac_starts (md_context_t *ctx, const unsigned char *key, size_t keylen)
Generic HMAC context setup.
int md_hmac_update (md_context_t *ctx, const unsigned char *input, size_t ilen)
Generic HMAC process buffer.
int md_hmac_finish (md_context_t *ctx, unsigned char *output)
Generic HMAC final digest.
int md_hmac_reset (md_context_t *ctx)
Generic HMAC context reset.
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 )
Detailed Description
Generic message digest wrapper.
Author: Adriaan de Jong <dejong@fox-it.com >
Copyright (C) 2006-2014, Brainspark B.V.
This file is part of PolarSSL (http://www.polarssl.org ) Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
All rights reserved.
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.
Definition in file md.h .
Function Documentation
int md
(
const md_info_t *
md_info ,
const unsigned char *
input ,
size_t
ilen ,
unsigned char *
output
)
Output = message_digest( input buffer )
Parameters:
md_info message digest info
input buffer holding the data
ilen length of the input data
output Generic message digest checksum result
Returns: 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter verification fails.
Definition at line 228 of file md.c .
int md_file
(
const md_info_t *
md_info ,
const char *
path ,
unsigned char *
output
)
Output = message_digest( file contents )
Parameters:
md_info message digest info
path input file name
output generic message digest checksum result
Returns: 0 if successful, POLARSSL_ERR_MD_FILE_OPEN_FAILED if fopen failed, POLARSSL_ERR_MD_FILE_READ_FAILED if fread failed, POLARSSL_ERR_MD_BAD_INPUT_DATA if md_info was NULL.
Definition at line 239 of file md.c .
int md_finish
(
md_context_t *
ctx ,
unsigned char *
output
)
Generic message digest final digest.
Parameters:
ctx Generic message digest context
output Generic message digest checksum result
Returns: 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter verification fails.
Definition at line 218 of file md.c .
Free the message-specific context of ctx.
Freeing ctx itself remains the responsibility of the caller.
Parameters:
ctx Free the message-specific context
Returns: 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter verification fails.
Definition at line 187 of file md.c .
static const char* md_get_name
(
const md_info_t *
md_info )
[static]
Returns the name of the message digest output.
Parameters:
md_info message digest info
Returns: name of the message digest output.
Definition at line 238 of file md.h .
static unsigned char md_get_size
(
const md_info_t *
md_info )
[static]
Returns the size of the message digest output.
Parameters:
md_info message digest info
Returns: size of the message digest output.
Definition at line 208 of file md.h .
static md_type_t md_get_type
(
const md_info_t *
md_info )
[static]
Returns the type of the message digest output.
Parameters:
md_info message digest info
Returns: type of the message digest output.
Definition at line 223 of file md.h .
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 )
Parameters:
md_info message digest info
key HMAC secret key
keylen length of the HMAC key
input buffer holding the data
ilen length of the input data
output Generic HMAC-result
Returns: 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter verification fails.
Definition at line 302 of file md.c .
int md_hmac_finish
(
md_context_t *
ctx ,
unsigned char *
output
)
Generic HMAC final digest.
Parameters:
ctx HMAC context
output Generic HMAC checksum result
Returns: 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter verification fails.
Definition at line 282 of file md.c .
Generic HMAC context reset.
Parameters:
ctx HMAC context to be reset
Returns: 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter verification fails.
Definition at line 292 of file md.c .
int md_hmac_starts
(
md_context_t *
ctx ,
const unsigned char *
key ,
size_t
keylen
)
Generic HMAC context setup.
Parameters:
ctx HMAC context to be initialized
key HMAC secret key
keylen length of the HMAC key
Returns: 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter verification fails.
Definition at line 262 of file md.c .
int md_hmac_update
(
md_context_t *
ctx ,
const unsigned char *
input ,
size_t
ilen
)
Generic HMAC process buffer.
Parameters:
ctx HMAC context
input buffer holding the data
ilen length of the input data
Returns: 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter verification fails.
Definition at line 272 of file md.c .
const md_info_t * md_info_from_string
(
const char *
md_name )
Returns the message digest information associated with the given digest name.
Parameters:
md_name Name of the digest to search for.
Returns: The message digest information associated with md_name or NULL if not found.
Definition at line 88 of file md.c .
const md_info_t * md_info_from_type
(
md_type_t
md_type )
Returns the message digest information associated with the given digest type.
Parameters:
md_type type of digest to search for.
Returns: The message digest information associated with md_type or NULL if not found.
Definition at line 129 of file md.c .
Initialises and fills the message digest context structure with the appropriate values.
Parameters:
ctx context to initialise. May not be NULL. The digest-specific context (ctx->md_ctx) must be NULL. It will be allocated, and must be freed using md_free_ctx() later.
md_info message digest to use.
Returns: 0
on success, POLARSSL_ERR_MD_BAD_INPUT_DATA
on parameter failure, POLARSSL_ERR_MD_ALLOC_FAILED
if allocation of the digest-specific context failed.
Definition at line 170 of file md.c .
const int* md_list
(
void
)
Returns the list of digests supported by the generic digest module.
Returns: a statically allocated array of digests, the last entry is 0.
Definition at line 83 of file md.c .
Set-up the given context for a new message digest.
Parameters:
ctx generic message digest context.
Returns: 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter verification fails.
Definition at line 198 of file md.c .
int md_update
(
md_context_t *
ctx ,
const unsigned char *
input ,
size_t
ilen
)
Generic message digest process buffer.
Parameters:
ctx Generic message digest context
input buffer holding the datal
ilen length of the input data
Returns: 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter verification fails.
Definition at line 208 of file md.c .