E-MailRelay

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Member Functions | Static Public Member Functions | List of all members
G::Hash Class Reference

A class for creating HMACs using an arbitrary cryptographic hash function. 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, size_t blocksize, const std::string &k)

## Static Public Member Functions
template<typename Fn2 >
static std::string | hmac (Fn2 digest, size_t blocksize, const std::string &key, const std::string &input)
| Computes a Hashed Message Authentication Code using 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.
template<typename Fn1 , typename Fn2 >
static std::string | mask (Fn1 predigest, Fn2 digest, 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...

## Detailed Description

A class for creating HMACs using an arbitrary cryptographic hash function.

Definition at line 36 of file ghash.h.

## Member Function Documentation

template<typename Fn2 >

std::string G::Hash::hmac | ( | Fn2 | digest,
|  | size_t | blocksize,
|  | const std::string & | key,
|  | const std::string & | input
| ) |  |
| inline static

Computes a Hashed Message Authentication Code using 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 has 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:

< 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 114 of file ghash.h.

template<typename Fn1 , typename Fn2 >

static std::string G::Hash::mask | ( | Fn1 | predigest,
|  | Fn2 | digest,
|  | size_t | blocksize,
|  | const std::string & | shared_key
| ) |  |
| 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.

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.

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

std::string G::Hash::printable | ( | const std::string & | input | ) |
| static

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

Definition at line 53 of file ghash.cpp.

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

- /tmp/slackrepo/SBo/slackrepo.S3SYfd/build_emailrelay/emailrelay-2.0.1/src/glib/ghash.h
- /tmp/slackrepo/SBo/slackrepo.S3SYfd/build_emailrelay/emailrelay-2.0.1/src/glib/ghash.cpp