DSL
Classes | Functions
HMAC Functions

Classes

struct  HASH_HMAC_CTX
 

Functions

DSL_API HASH_HMAC_CTX *DSL_CC hmac_init (const char *name, const uint8 *key, size_t length)
 
DSL_API void DSL_CC hmac_update (HASH_HMAC_CTX *ctx, const uint8 *input, size_t length)
 Call with the data you want to hash, can be called multiple times to hash a large file in chunks for example.
 
DSL_API bool DSL_CC hmac_finish (HASH_HMAC_CTX *ctx, uint8 *out, size_t outlen)
 Finalize HMAC and store in out. outlen should be >= hashSize in the HASH_CTX struct. After this no further calls to hmac_update() can be made and ctx is destroyed.
 
DSL_API bool DSL_CC hmacdata (const char *name, const uint8 *key, size_t keylen, const uint8 *data, size_t datalen, char *out, size_t outlen)
 Wrapper around hmac_init()/hmac_update()/hmac_finish(). If raw_output == true out will contain binary data, otherwise will contain a hex string.
 
DSL_API bool DSL_CC hmacfile (const char *name, const uint8 *key, size_t keylen, const char *fn, char *out, size_t outlen)
 Wrapper around hmac_init()/hmac_update()/hmac_finish(). If raw_output == true out will contain binary data, otherwise will contain a hex string.
 
DSL_API bool DSL_CC hmacfile_fp (const char *name, const uint8 *key, size_t keylen, FILE *fp, char *out, size_t outlen)
 Wrapper around hmac_init()/hmac_update()/hmac_finish(). If raw_output == true out will contain binary data, otherwise will contain a hex string.
 
DSL_API bool DSL_CC hmacfile_rw (const char *name, const uint8 *key, size_t keylen, DSL_FILE *fp, char *out, size_t outlen)
 Wrapper around hmac_init()/hmac_update()/hmac_finish(). If raw_output == true out will contain binary data, otherwise will contain a hex string.
 

Detailed Description

Function Documentation

◆ hmac_init()

DSL_API HASH_HMAC_CTX* DSL_CC hmac_init ( const char *  name,
const uint8 *  key,
size_t  length 
)

Initialize a HMAC CTX with hashing algorithm 'name'
This feature relies on having external libraries enabled:
With ENABLE_OPENSSL: Adds the full range of OpenSSL supported hash algorithms
With ENABLE_GNUTLS: Adds sha256, sha512, sha1, md5, RIPEMD-160, MD2, SHA224, SHA384
See hmacdata(), hmacfile(), hmacfile_fp(), and hmacfile_rw() for one-shot convenience functions. The hmacfile* ones automatically HMAC the file in 32K chunks so it won't try to load the entire file into memory or anything.

Parameters
nameThe name of the hashing algorithm.
keyThe secret key to use.
lengthThe length of the secret key.

Definition at line 47 of file hmac.cpp.

Referenced by hmacdata(), and hmacfile_rw().