MistServer  2.5.3-Pro-19-gf5e75b1 ( Generic_64)
Functions
Secure Namespace Reference

Functions

std::string hmac (std::string msg, std::string key, unsigned int hashSize, void hasher(const char *, const unsigned int, char *), unsigned int blockSize)
 Performs HMAC on msg with given key. More...
 
std::string hmac (const char *msg, const unsigned int msg_len, const char *key, const unsigned int key_len, unsigned int hashSize, void hasher(const char *, const unsigned int, char *), unsigned int blockSize)
 Performs HMAC on msg with given key. More...
 
std::string hmac_sha256 (std::string msg, std::string key)
 Convenience function that returns the hexadecimal alphanumeric HMAC-SHA256 of msg and key. More...
 
std::string hmac_sha256 (const char *msg, const unsigned int msg_len, const char *key, const unsigned int key_len)
 Convenience function that returns the hexadecimal alphanumeric HMAC-SHA256 of msg and key. More...
 
void hmac_sha256bin (const char *msg, const unsigned int msg_len, const char *key, const unsigned int key_len, char *output)
 Convenience function that sets output to the HMAC-SHA256 of msg and key in binary format. More...
 
void hmacbin (const char *msg, const unsigned int msg_len, const char *key, const unsigned int key_len, unsigned int hashSize, void hasher(const char *, const unsigned int, char *), unsigned int blockSize, char *output)
 Performs HMAC on msg with given key. More...
 
std::string md5 (std::string input)
 Calculates a MD5 digest as per rfc1321, returning it as a hexadecimal alphanumeric string. More...
 
std::string md5 (const char *input, const unsigned int in_len)
 Calculates a MD5 digest as per rfc1321, returning it as a hexadecimal alphanumeric string. More...
 
static void md5_add64 (uint32_t *hash, const char *data)
 Adds 64 bytes of data to the current MD5 hash. More...
 
void md5bin (const char *input, const unsigned int in_len, char *output)
 Calculates a MD5 digest as per rfc1321, returning it as binary. More...
 
static uint32_t rr (uint32_t x, uint32_t c)
 Right rotate function. Shifts bytes off the least significant end, wrapping them to the most significant end. More...
 
std::string sha256 (std::string input)
 Calculates a SHA256 digest as per NSAs SHA-2, returning it as a hexadecimal alphanumeric string. More...
 
std::string sha256 (const char *input, const unsigned int in_len)
 Calculates a SHA256 digest as per NSAs SHA-2, returning it as a hexadecimal alphanumeric string. More...
 
static void sha256_add64 (uint32_t *hash, const char *data)
 Adds 64 bytes of data to the current SHA256 hash. More...
 
void sha256bin (const char *input, const unsigned int in_len, char *output)
 Calculates a SHA256 digest as per NSAs SHA-2, returning it as binary. More...
 

Function Documentation

std::string Secure::hmac ( std::string  msg,
std::string  key,
unsigned int  hashSize,
void   hasherconst char *, const unsigned int, char *,
unsigned int  blockSize 
)

Performs HMAC on msg with given key.

Uses given hasher function, requires hashSize to be set accordingly. Output is returned as hexadecimal alphanumeric string. The hasher function must be the "bin" version of the hasher to have a compatible function signature.

std::string Secure::hmac ( const char *  msg,
const unsigned int  msg_len,
const char *  key,
const unsigned int  key_len,
unsigned int  hashSize,
void   hasherconst char *, const unsigned int, char *,
unsigned int  blockSize 
)

Performs HMAC on msg with given key.

Uses given hasher function, requires hashSize to be set accordingly. Output is returned as hexadecimal alphanumeric string. The hasher function must be the "bin" version of the hasher to have a compatible function signature.

std::string Secure::hmac_sha256 ( std::string  msg,
std::string  key 
)

Convenience function that returns the hexadecimal alphanumeric HMAC-SHA256 of msg and key.

std::string Secure::hmac_sha256 ( const char *  msg,
const unsigned int  msg_len,
const char *  key,
const unsigned int  key_len 
)

Convenience function that returns the hexadecimal alphanumeric HMAC-SHA256 of msg and key.

void Secure::hmac_sha256bin ( const char *  msg,
const unsigned int  msg_len,
const char *  key,
const unsigned int  key_len,
char *  output 
)

Convenience function that sets output to the HMAC-SHA256 of msg and key in binary format.

Assumes at least 32 bytes are available for writing in output.

void Secure::hmacbin ( const char *  msg,
const unsigned int  msg_len,
const char *  key,
const unsigned int  key_len,
unsigned int  hashSize,
void   hasherconst char *, const unsigned int, char *,
unsigned int  blockSize,
char *  output 
)

Performs HMAC on msg with given key.

Uses given hasher function, requires hashSize to be set accordingly. Output is written in binary form to output, and assumes hashSize bytes are available to be written to. The hasher function must be the "bin" version of the hasher to have a compatible function signature.

std::string Secure::md5 ( std::string  input)

Calculates a MD5 digest as per rfc1321, returning it as a hexadecimal alphanumeric string.

std::string Secure::md5 ( const char *  input,
const unsigned int  in_len 
)

Calculates a MD5 digest as per rfc1321, returning it as a hexadecimal alphanumeric string.

static void Secure::md5_add64 ( uint32_t *  hash,
const char *  data 
)
inlinestatic

Adds 64 bytes of data to the current MD5 hash.

hash is the current hash, represented by 4 unsigned longs. data is the 64 bytes of data that need to be added.

void Secure::md5bin ( const char *  input,
const unsigned int  in_len,
char *  output 
)

Calculates a MD5 digest as per rfc1321, returning it as binary.

Assumes output is big enough to contain 16 bytes of data.

static uint32_t Secure::rr ( uint32_t  x,
uint32_t  c 
)
inlinestatic

Right rotate function. Shifts bytes off the least significant end, wrapping them to the most significant end.

std::string Secure::sha256 ( std::string  input)

Calculates a SHA256 digest as per NSAs SHA-2, returning it as a hexadecimal alphanumeric string.

std::string Secure::sha256 ( const char *  input,
const unsigned int  in_len 
)

Calculates a SHA256 digest as per NSAs SHA-2, returning it as a hexadecimal alphanumeric string.

static void Secure::sha256_add64 ( uint32_t *  hash,
const char *  data 
)
inlinestatic

Adds 64 bytes of data to the current SHA256 hash.

hash is the current hash, represented by 8 unsigned longs. data is the 64 bytes of data that need to be added.

void Secure::sha256bin ( const char *  input,
const unsigned int  in_len,
char *  output 
)

Calculates a SHA256 digest as per NSAs SHA-2, returning it as binary.

Assumes output is big enough to contain 16 bytes of data.