E-MailRelay
|
A class for creating HMACs using an arbitrary cryptographic hash function as per RFC-2104. More...
#include <ghash.h>
Classes | |
struct | Masked |
An overload discriminator for G::Hash::hmac() More... | |
Public Member Functions | |
template<typename Fn , typename Fn2 > | |
std::string | mask (Fn predigest_fn, Fn2 digest_fn, std::size_t blocksize, const std::string &k) |
Static Public Member Functions | |
template<typename Fn2 > | |
static std::string | hmac (Fn2 digest, std::size_t blocksize, const std::string &key, const std::string &input) |
Computes a Hashed Message Authentication Code using the given hash function. More... | |
template<typename Fn2 > | |
static std::string | hmac (Fn2 postdigest, const std::string &masked_key, const std::string &input, Masked) |
An hmac() overload using a masked key. More... | |
template<typename Fn1 , typename Fn2 > | |
static std::string | mask (Fn1 predigest, Fn2 digest, std::size_t blocksize, const std::string &shared_key) |
Computes a masked key from the given shared key, returning a non-printable string. More... | |
static std::string | printable (const std::string &input) |
Converts a binary string into a printable form, using a lowercase hexadecimal encoding. More... | |
A class for creating HMACs using an arbitrary cryptographic hash function as per RFC-2104.
|
static |
Computes a Hashed Message Authentication Code using the given hash function.
This is typically for challenge-response authentication where the plaintext input is an arbitrary challenge string from the server that the client needs to hmac() using their shared private key.
See also RFC-2104 [HMAC-MD5].
For hash function H with block size B (64) using shared key SK:
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.
|
static |
An hmac() overload using a masked key.
The postdigest function should behave like G::Md5::postdigest() and it must throw an exception if the masked key is invalid.
std::string G::Hash::mask | ( | Fn | predigest_fn, |
Fn2 | digest_fn, | ||
std::size_t | blocksize, | ||
const std::string & | k | ||
) |
|
static |
Computes a masked key from the given shared key, returning a non-printable string.
This can be passed to the 'masked' overload of hmac() once the message is known.
The predigest and digest functions must behave like G::Md5::predigest() and G::Md5::digest2().
A masked key (MK) is the result of doing the initial, plaintext-independent parts of HMAC computation, taking the intermediate state of both the inner and outer hash functions.
|
static |