RetroArch
Functions | Variables
md.c File Reference
#include "mbedtls/config.h"
#include "mbedtls/md.h"
#include "mbedtls/md_internal.h"
#include "mbedtls/platform.h"
#include <string.h>
#include <stdio.h>
#include "arc4_alt.h"
Include dependency graph for md.c:

Functions

const int * mbedtls_md_list (void)
 Returns the list of digests supported by the generic digest module. More...
 
const mbedtls_md_info_tmbedtls_md_info_from_string (const char *md_name)
 Returns the message digest information associated with the given digest name. More...
 
const mbedtls_md_info_tmbedtls_md_info_from_type (mbedtls_md_type_t md_type)
 Returns the message digest information associated with the given digest type. More...
 
void mbedtls_md_init (mbedtls_md_context_t *ctx)
 Initialize a md_context (as NONE) This should always be called first. Prepares the context for mbedtls_md_setup() or mbedtls_md_free(). More...
 
void mbedtls_md_free (mbedtls_md_context_t *ctx)
 Free and clear the internal structures of ctx. Can be called at any time after mbedtls_md_init(). Mandatory once mbedtls_md_setup() has been called. More...
 
int mbedtls_md_clone (mbedtls_md_context_t *dst, const mbedtls_md_context_t *src)
 Clone the state of an MD context. More...
 
int mbedtls_md_init_ctx (mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info)
 Select MD to use and allocate internal structures. Should be called after mbedtls_md_init() or mbedtls_md_free(). Makes it necessary to call mbedtls_md_free() later. More...
 
int mbedtls_md_setup (mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac)
 Select MD to use and allocate internal structures. Should be called after mbedtls_md_init() or mbedtls_md_free(). Makes it necessary to call mbedtls_md_free() later. More...
 
int mbedtls_md_starts (mbedtls_md_context_t *ctx)
 Prepare the context to digest a new message. Generally called after mbedtls_md_setup() or mbedtls_md_finish(). Followed by mbedtls_md_update(). More...
 
int mbedtls_md_update (mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen)
 Generic message digest process buffer Called between mbedtls_md_starts() and mbedtls_md_finish(). May be called repeatedly. More...
 
int mbedtls_md_finish (mbedtls_md_context_t *ctx, unsigned char *output)
 Generic message digest final digest Called after mbedtls_md_update(). Usually followed by mbedtls_md_free() or mbedtls_md_starts(). More...
 
int mbedtls_md (const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen, unsigned char *output)
 Output = message_digest( input buffer ) More...
 
int mbedtls_md_file (const mbedtls_md_info_t *md_info, const char *path, unsigned char *output)
 
int mbedtls_md_hmac_starts (mbedtls_md_context_t *ctx, const unsigned char *key, size_t keylen)
 Set HMAC key and prepare to authenticate a new message. Usually called after mbedtls_md_setup() or mbedtls_md_hmac_finish(). More...
 
int mbedtls_md_hmac_update (mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen)
 Generic HMAC process buffer. Called between mbedtls_md_hmac_starts() or mbedtls_md_hmac_reset() and mbedtls_md_hmac_finish(). May be called repeatedly. More...
 
int mbedtls_md_hmac_finish (mbedtls_md_context_t *ctx, unsigned char *output)
 Output HMAC. Called after mbedtls_md_hmac_update(). Usually followed by mbedtls_md_hmac_reset(), mbedtls_md_hmac_starts(), or mbedtls_md_free(). More...
 
int mbedtls_md_hmac_reset (mbedtls_md_context_t *ctx)
 Prepare to authenticate a new message with the same key. Called after mbedtls_md_hmac_finish() and before mbedtls_md_hmac_update(). More...
 
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)
 Output = Generic_HMAC( hmac key, input buffer ) More...
 
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)
 Returns the size of the message digest output. More...
 
mbedtls_md_type_t mbedtls_md_get_type (const mbedtls_md_info_t *md_info)
 Returns the type of the message digest output. More...
 
const char * mbedtls_md_get_name (const mbedtls_md_info_t *md_info)
 Returns the name of the message digest output. More...
 

Variables

static const int supported_digests []
 

Function Documentation

◆ mbedtls_md()

int mbedtls_md ( const mbedtls_md_info_t md_info,
const unsigned char *  input,
size_t  ilen,
unsigned char *  output 
)

Output = message_digest( input buffer )

Parameters
md_infomessage digest info
inputbuffer holding the data
ilenlength of the input data
outputGeneric message digest checksum result
Returns
0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter verification fails.
Here is the caller graph for this function:

◆ mbedtls_md_clone()

int mbedtls_md_clone ( mbedtls_md_context_t dst,
const mbedtls_md_context_t src 
)

Clone the state of an MD context.

Note
The two contexts must have been setup to the same type (cloning from SHA-256 to SHA-512 make no sense).
Warning
Only clones the MD state, not the HMAC state! (for now)
Parameters
dstThe destination context
srcThe context to be cloned
Returns
0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure.

◆ mbedtls_md_file()

int mbedtls_md_file ( const mbedtls_md_info_t md_info,
const char *  path,
unsigned char *  output 
)
Here is the call graph for this function:

◆ mbedtls_md_finish()

int mbedtls_md_finish ( mbedtls_md_context_t ctx,
unsigned char *  output 
)

Generic message digest final digest Called after mbedtls_md_update(). Usually followed by mbedtls_md_free() or mbedtls_md_starts().

Parameters
ctxGeneric message digest context
outputGeneric message digest checksum result
Returns
0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter verification fails.
Here is the caller graph for this function:

◆ mbedtls_md_free()

void mbedtls_md_free ( mbedtls_md_context_t ctx)

Free and clear the internal structures of ctx. Can be called at any time after mbedtls_md_init(). Mandatory once mbedtls_md_setup() has been called.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_md_get_name()

const char* mbedtls_md_get_name ( const mbedtls_md_info_t md_info)

Returns the name of the message digest output.

Parameters
md_infomessage digest info
Returns
name of the message digest output.
Here is the caller graph for this function:

◆ mbedtls_md_get_size()

unsigned char mbedtls_md_get_size ( const mbedtls_md_info_t md_info)

Returns the size of the message digest output.

Parameters
md_infomessage digest info
Returns
size of the message digest output in bytes.
Here is the caller graph for this function:

◆ mbedtls_md_get_type()

mbedtls_md_type_t mbedtls_md_get_type ( const mbedtls_md_info_t md_info)

Returns the type of the message digest output.

Parameters
md_infomessage digest info
Returns
type of the message digest output.

◆ mbedtls_md_hmac()

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 
)

Output = Generic_HMAC( hmac key, input buffer )

Parameters
md_infomessage digest info
keyHMAC secret key
keylenlength of the HMAC key in bytes
inputbuffer holding the data
ilenlength of the input data
outputGeneric HMAC-result
Returns
0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter verification fails.
Here is the call graph for this function:

◆ mbedtls_md_hmac_finish()

int mbedtls_md_hmac_finish ( mbedtls_md_context_t ctx,
unsigned char *  output 
)

Output HMAC. Called after mbedtls_md_hmac_update(). Usually followed by mbedtls_md_hmac_reset(), mbedtls_md_hmac_starts(), or mbedtls_md_free().

Parameters
ctxHMAC context
outputGeneric HMAC checksum result
Returns
0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter verification fails.
Here is the caller graph for this function:

◆ mbedtls_md_hmac_reset()

int mbedtls_md_hmac_reset ( mbedtls_md_context_t ctx)

Prepare to authenticate a new message with the same key. Called after mbedtls_md_hmac_finish() and before mbedtls_md_hmac_update().

Parameters
ctxHMAC context to be reset
Returns
0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter verification fails.
Here is the caller graph for this function:

◆ mbedtls_md_hmac_starts()

int mbedtls_md_hmac_starts ( mbedtls_md_context_t ctx,
const unsigned char *  key,
size_t  keylen 
)

Set HMAC key and prepare to authenticate a new message. Usually called after mbedtls_md_setup() or mbedtls_md_hmac_finish().

Parameters
ctxHMAC context
keyHMAC secret key
keylenlength of the HMAC key in bytes
Returns
0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter verification fails.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_md_hmac_update()

int mbedtls_md_hmac_update ( mbedtls_md_context_t ctx,
const unsigned char *  input,
size_t  ilen 
)

Generic HMAC process buffer. Called between mbedtls_md_hmac_starts() or mbedtls_md_hmac_reset() and mbedtls_md_hmac_finish(). May be called repeatedly.

Parameters
ctxHMAC context
inputbuffer holding the data
ilenlength of the input data
Returns
0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter verification fails.
Here is the caller graph for this function:

◆ mbedtls_md_info_from_string()

const mbedtls_md_info_t* mbedtls_md_info_from_string ( const char *  md_name)

Returns the message digest information associated with the given digest name.

Parameters
md_nameName of the digest to search for.
Returns
The message digest information associated with md_name or NULL if not found.
Here is the call graph for this function:

◆ mbedtls_md_info_from_type()

const mbedtls_md_info_t* mbedtls_md_info_from_type ( mbedtls_md_type_t  md_type)

Returns the message digest information associated with the given digest type.

Parameters
md_typetype of digest to search for.
Returns
The message digest information associated with md_type or NULL if not found.
Here is the caller graph for this function:

◆ mbedtls_md_init()

void mbedtls_md_init ( mbedtls_md_context_t ctx)

Initialize a md_context (as NONE) This should always be called first. Prepares the context for mbedtls_md_setup() or mbedtls_md_free().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_md_init_ctx()

int mbedtls_md_init_ctx ( mbedtls_md_context_t ctx,
const mbedtls_md_info_t md_info 
)

Select MD to use and allocate internal structures. Should be called after mbedtls_md_init() or mbedtls_md_free(). Makes it necessary to call mbedtls_md_free() later.

Deprecated:
Superseded by mbedtls_md_setup() in 2.0.0
Parameters
ctxContext to set up.
md_infoMessage digest to use.
Returns
0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure, MBEDTLS_ERR_MD_ALLOC_FAILED memory allocation failure.
Here is the call graph for this function:

◆ mbedtls_md_list()

const int* mbedtls_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.

◆ mbedtls_md_process()

int mbedtls_md_process ( mbedtls_md_context_t ctx,
const unsigned char *  data 
)
Here is the caller graph for this function:

◆ mbedtls_md_setup()

int mbedtls_md_setup ( mbedtls_md_context_t ctx,
const mbedtls_md_info_t md_info,
int  hmac 
)

Select MD to use and allocate internal structures. Should be called after mbedtls_md_init() or mbedtls_md_free(). Makes it necessary to call mbedtls_md_free() later.

Parameters
ctxContext to set up.
md_infoMessage digest to use.
hmac0 to save some memory if HMAC will not be used, non-zero is HMAC is going to be used with this context.
Returns
0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure, MBEDTLS_ERR_MD_ALLOC_FAILED memory allocation failure.
Here is the caller graph for this function:

◆ mbedtls_md_starts()

int mbedtls_md_starts ( mbedtls_md_context_t ctx)

Prepare the context to digest a new message. Generally called after mbedtls_md_setup() or mbedtls_md_finish(). Followed by mbedtls_md_update().

Parameters
ctxgeneric message digest context.
Returns
0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter verification fails.
Here is the caller graph for this function:

◆ mbedtls_md_update()

int mbedtls_md_update ( mbedtls_md_context_t ctx,
const unsigned char *  input,
size_t  ilen 
)

Generic message digest process buffer Called between mbedtls_md_starts() and mbedtls_md_finish(). May be called repeatedly.

Parameters
ctxGeneric message digest context
inputbuffer holding the datal
ilenlength of the input data
Returns
0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter verification fails.
Here is the caller graph for this function:

Variable Documentation

◆ supported_digests

const int supported_digests[]
static