# md.h File Reference

`#include <gwenhywfar/gwenhywfarapi.h>`
`#include <gwenhywfar/error.h>`
`#include <gwenhywfar/buffer.h>`

Go to the source code of this file.

## Functions for Inheriting Modules

These function should not be called by applications. They are meant to be called by modules implementing message digest code.
GWENHYWFAR_API void * | GWEN_MD_GetData (GWEN_MD *md)
GWENHYWFAR_API GWEN_MD * | GWEN_MD_new (unsigned int size)
GWENHYWFAR_API void | GWEN_MD_SetBeginFn (GWEN_MD *md, GWEN_MD_BEGIN_FN fn)
GWENHYWFAR_API void | GWEN_MD_SetData (GWEN_MD *md, void *data)
GWENHYWFAR_API void | GWEN_MD_SetEndFn (GWEN_MD *md, GWEN_MD_END_FN fn)
GWENHYWFAR_API void | GWEN_MD_SetFreeDataFn (GWEN_MD *md, GWEN_MD_FREEDATA_FN fn)
GWENHYWFAR_API void | GWEN_MD_SetUpdateFn (GWEN_MD *md, GWEN_MD_UPDATE_FN fn)

## Typedefs

typedef GWEN_MD | GWEN_MD
typedef int(* | GWEN_MD_BEGIN_FN )(GWEN_MD *md)
typedef int(* | GWEN_MD_END_FN )(GWEN_MD *md)
typedef void(* | GWEN_MD_FREEDATA_FN )(GWEN_MD *md)
typedef GWEN_MD_PROVIDER | GWEN_MD_PROVIDER
typedef int(* | GWEN_MD_UPDATE_FN )(GWEN_MD *md, const char *buf, unsigned int l)
typedef GWEN_MD *(* | GWEN_MDPROVIDER_NEWMD_FN )(GWEN_MD_PROVIDER *pr)

## Functions

GWENHYWFAR_API int | GWEN_MD_Begin (GWEN_MD *md)
GWENHYWFAR_API int | GWEN_MD_End (GWEN_MD *md)
GWENHYWFAR_API GWEN_MD * | GWEN_MD_Factory (const char *t)
GWENHYWFAR_API void | GWEN_MD_free (GWEN_MD *md)
GWENHYWFAR_API unsigned char * | GWEN_MD_GetDigestPtr (GWEN_MD *md)
GWENHYWFAR_API unsigned int | GWEN_MD_GetDigestSize (GWEN_MD *md)
GWENHYWFAR_API int | GWEN_MD_Hash (const char *algo, const char *data, unsigned int dsize, char *buffer, unsigned int *bsize)
GWENHYWFAR_API int | GWEN_MD_HashToBuffer (const char *typ, const char *data, unsigned int dsize, GWEN_BUFFER *dstBuf)
GWENHYWFAR_API GWEN_ERRORCODE | GWEN_MD_RegisterProvider (GWEN_MD_PROVIDER *pr)
GWENHYWFAR_API void | GWEN_MD_UnregisterAllProviders ()
GWENHYWFAR_API GWEN_ERRORCODE | GWEN_MD_UnregisterProvider (GWEN_MD_PROVIDER *pr)
GWENHYWFAR_API int | GWEN_MD_Update (GWEN_MD *md, const char *buf, unsigned int l)
GWENHYWFAR_API void | GWEN_MdProvider_free (GWEN_MD_PROVIDER *pr)
GWENHYWFAR_API GWEN_MD_PROVIDER * | GWEN_MdProvider_new ()
GWENHYWFAR_API void | GWEN_MdProvider_SetName (GWEN_MD_PROVIDER *pr, const char *name)
GWENHYWFAR_API void | GWEN_MdProvider_SetNewMdFn (GWEN_MD_PROVIDER *pr, GWEN_MDPROVIDER_NEWMD_FN newMdFn)

## Typedef Documentation

typedef struct GWEN_MD GWEN_MD

typedef int(* GWEN_MD_BEGIN_FN)(GWEN_MD *md)

typedef int(* GWEN_MD_END_FN)(GWEN_MD *md)

typedef void(* GWEN_MD_FREEDATA_FN)(GWEN_MD *md)

typedef struct GWEN_MD_PROVIDER GWEN_MD_PROVIDER

typedef int(* GWEN_MD_UPDATE_FN)(GWEN_MD *md, const char *buf, unsigned int l)

typedef GWEN_MD*(* GWEN_MDPROVIDER_NEWMD_FN)(GWEN_MD_PROVIDER *pr)

## Function Documentation

GWENHYWFAR_API int GWEN_MD_Begin | ( | GWEN_MD * | md | ) |

GWENHYWFAR_API int GWEN_MD_End | ( | GWEN_MD * | md | ) |

GWENHYWFAR_API GWEN_MD* GWEN_MD_Factory | ( | const char * | t | ) |

GWENHYWFAR_API void GWEN_MD_free | ( | GWEN_MD * | md | ) |

GWENHYWFAR_API void* GWEN_MD_GetData | ( | GWEN_MD * | md | ) |

GWENHYWFAR_API unsigned char* GWEN_MD_GetDigestPtr | ( | GWEN_MD * | md | ) |

GWENHYWFAR_API unsigned int GWEN_MD_GetDigestSize | ( | GWEN_MD * | md | ) |

GWENHYWFAR_API int GWEN_MD_Hash | ( | const char * | algo,
|  | const char * | data,
|  | unsigned int | dsize,
|  | char * | buffer,
|  | unsigned int * | bsize
| ) |

This is a conveniance function. It hashes a given data buffer using the given hash algo.

Returns:
  0 if ok, !=0 on error

Parameters:

  | algo | algorithm name (like "RMD160", "MD5")
  | data | pointer to the data to hash
  | dsize | size of the data to hash
  | buffer | pointer to a buffer for the hash
  | bsize | pointer to a variable that initially holds the size of the buffer. Upon return it will hold the size of the hash data.

GWENHYWFAR_API int GWEN_MD_HashToBuffer | ( | const char * | typ,
|  | const char * | data,
|  | unsigned int | dsize,
|  | GWEN_BUFFER * | dstBuf
| ) |

GWENHYWFAR_API GWEN_MD* GWEN_MD_new | ( | unsigned int | size | ) |

GWENHYWFAR_API GWEN_ERRORCODE GWEN_MD_RegisterProvider | ( | GWEN_MD_PROVIDER * | pr | ) |

| On success this function takes over ownership of the given object.

GWENHYWFAR_API void GWEN_MD_SetBeginFn | ( | GWEN_MD * | md,
|  | GWEN_MD_BEGIN_FN | fn
| ) |

GWENHYWFAR_API void GWEN_MD_SetData | ( | GWEN_MD * | md,
|  | void * | data
| ) |

GWENHYWFAR_API void GWEN_MD_SetEndFn | ( | GWEN_MD * | md,
|  | GWEN_MD_END_FN | fn
| ) |

GWENHYWFAR_API void GWEN_MD_SetFreeDataFn | ( | GWEN_MD * | md,
|  | GWEN_MD_FREEDATA_FN | fn
| ) |

GWENHYWFAR_API void GWEN_MD_SetUpdateFn | ( | GWEN_MD * | md,
|  | GWEN_MD_UPDATE_FN | fn
| ) |

GWENHYWFAR_API void GWEN_MD_UnregisterAllProviders | ( |  | ) |

GWENHYWFAR_API GWEN_ERRORCODE GWEN_MD_UnregisterProvider | ( | GWEN_MD_PROVIDER * | pr | ) |

GWENHYWFAR_API int GWEN_MD_Update | ( | GWEN_MD * | md,
|  | const char * | buf,
|  | unsigned int | l
| ) |

GWENHYWFAR_API void GWEN_MdProvider_free | ( | GWEN_MD_PROVIDER * | pr | ) |

GWENHYWFAR_API GWEN_MD_PROVIDER* GWEN_MdProvider_new | ( |  | ) |

GWENHYWFAR_API void GWEN_MdProvider_SetName | ( | GWEN_MD_PROVIDER * | pr,
|  | const char * | name
| ) |

GWENHYWFAR_API void GWEN_MdProvider_SetNewMdFn | ( | GWEN_MD_PROVIDER * | pr,
|  | GWEN_MDPROVIDER_NEWMD_FN | newMdFn
| ) |