VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
G::Md5 Class Reference

MD5 message digest class. More...

#include <gmd5.h>

Classes

struct  Masked
 An overload discriminator for G::Md5::hmac() More...
 

Static Public Member Functions

static std::string digest (const std::string &input)
 Creates an MD5 digest. More...
 
static std::string digest (const std::string &input_1, const std::string &input_2)
 An overload which processes two input strings.
 
static std::string printable (const std::string &input)
 Converts a binary string into a printable form, using a lowercase hexadecimal encoding. More...
 
static std::string hmac (const std::string &key, const std::string &input)
 Computes a Hashed Message Authentication Code using MD5 as the hash function. More...
 
static std::string hmac (const std::string &masked_key, const std::string &input, Masked)
 An hmac() overload using a masked key. More...
 
static std::string mask (const std::string &key)
 Computes a masked key for hmac() from the given shared key, returning a printable string. More...
 

Detailed Description

MD5 message digest class.

Definition at line 36 of file gmd5.h.

Member Function Documentation

std::string G::Md5::digest ( const std::string &  input)
static

Creates an MD5 digest.

The resulting string is not generally printable and it may have embedded NULs.

Definition at line 165 of file gmd5_native.cpp.

std::string G::Md5::hmac ( const std::string &  key,
const std::string &  input 
)
static

Computes a Hashed Message Authentication Code using MD5 as the hash function.

This is typically for challenge-response authentication where the plaintext input is an arbitrary challenge string from the server that the client has to hmac() using their shared private key.

See also RFC2104 [HMAC-MD5].

For hash function H with block size B (64) and output size L (16), using shared key SK:

< K = large(SK) ? H(SK) : SK
< ipad = 0x36 repeated B times
< opad = 0x5C repeated B times
< HMAC = H( K XOR opad , H( K XOR ipad , plaintext ) )
<

The H() function processes a stream of blocks; the first parameter above represents the first block, and the second parameter is the rest of the stream (zero-padded up to a block boundary).

The shared key can be up to B bytes, or if more than B bytes then K is the L-byte result of hashing the shared-key. K is zero-padded up to B bytes for XOR-ing.

Definition at line 159 of file gmd5_native.cpp.

std::string G::Md5::hmac ( const std::string &  masked_key,
const std::string &  input,
Masked   
)
static

An hmac() overload using a masked key.

A masked key (MK) is the result of doing the initial, plaintext-independent parts of HMAC computation, taking the intermediate results of both the inner and outer hash functions.

< K = large(SK) ? H(SK) : SK
< HKipad = H( K XOR ipad , )
< HKopad = H( K XOR opad , )
< MK := ( HKipad , HKopad )
<

Definition at line 143 of file gmd5_native.cpp.

std::string G::Md5::mask ( const std::string &  key)
static

Computes a masked key for hmac() from the given shared key, returning a printable string.

Definition at line 129 of file gmd5_native.cpp.

std::string G::Md5::printable ( const std::string &  input)
static

Converts a binary string into a printable form, using a lowercase hexadecimal encoding.

See also RFC2095.

Definition at line 185 of file gmd5_native.cpp.


The documentation for this class was generated from the following files: