- Main Page
- Namespaces
- Classes
- Files

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# DH2 Class Reference

`#include <dh2.h>`

Inheritance diagram for DH2:

List of all members.

## Detailed Description

Unified Diffie-Hellman

Definition at line 12 of file dh2.h.

## Public Member Functions
| DH2 (const SimpleKeyAgreementDomain &domain)
| DH2 (const SimpleKeyAgreementDomain &staticDomain, const SimpleKeyAgreementDomain &ephemeralDomain)
unsigned int | AgreedValueLength () const
| return length of agreed value produced
unsigned int | StaticPrivateKeyLength () const
| return length of static private keys in this domain
unsigned int | StaticPublicKeyLength () const
| return length of static public keys in this domain
void | GenerateStaticPrivateKey (RandomNumberGenerator &rng, byte *privateKey) const
| generate static private key
void | GenerateStaticPublicKey (RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
| generate static public key
void | GenerateStaticKeyPair (RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
| generate private/public key pair
unsigned int | EphemeralPrivateKeyLength () const
| return length of ephemeral private keys in this domain
unsigned int | EphemeralPublicKeyLength () const
| return length of ephemeral public keys in this domain
void | GenerateEphemeralPrivateKey (RandomNumberGenerator &rng, byte *privateKey) const
| generate ephemeral private key
void | GenerateEphemeralPublicKey (RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
| generate ephemeral public key
void | GenerateEphemeralKeyPair (RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
| generate private/public key pair
bool | Agree (byte *agreedValue, const byte *staticPrivateKey, const byte *ephemeralPrivateKey, const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey, bool validateStaticOtherPublicKey=true) const
| derive agreed value from your private keys and couterparty's public keys, return false in case of failure
CryptoMaterial & | AccessMaterial ()
| returns a reference to the crypto material used by this object
const CryptoMaterial & | GetMaterial () const
| returns a const reference to the crypto material used by this object
virtual CryptoParameters & | AccessCryptoParameters ()=0
virtual const CryptoParameters & | GetCryptoParameters () const
void | BERDecode (BufferedTransformation &bt)
| for backwards compatibility, calls AccessMaterial().Load(bt)
void | DEREncode (BufferedTransformation &bt) const
| for backwards compatibility, calls GetMaterial().Save(bt)
virtual std::string | AlgorithmName () const
| returns name of this algorithm, not universally implemented yet
virtual Clonable * | Clone () const
| this is not implemented by most classes yet
## Protected Attributes
const SimpleKeyAgreementDomain & | d1
const SimpleKeyAgreementDomain & | d2

## Member Function Documentation

void DH2::GenerateStaticPrivateKey | ( | RandomNumberGenerator & | rng,
|  | byte * | privateKey |
| ) |  |  | const`[inline, virtual]`

generate static private key

Precondition:
  size of privateKey == PrivateStaticKeyLength()

Implements AuthenticatedKeyAgreementDomain.

Definition at line 27 of file dh2.h.

void DH2::GenerateStaticPublicKey | ( | RandomNumberGenerator & | rng,
|  | const byte * | privateKey,
|  | byte * | publicKey |
| ) |  |  | const`[inline, virtual]`

generate static public key

Precondition:
  size of publicKey == PublicStaticKeyLength()

Implements AuthenticatedKeyAgreementDomain.

Definition at line 29 of file dh2.h.

void DH2::GenerateStaticKeyPair | ( | RandomNumberGenerator & | rng,
|  | byte * | privateKey,
|  | byte * | publicKey |
| ) |  |  | const`[inline, virtual]`

generate private/public key pair

Note:
  equivalent to calling GenerateStaticPrivateKey() and then GenerateStaticPublicKey()

Reimplemented from AuthenticatedKeyAgreementDomain.

Definition at line 31 of file dh2.h.

void DH2::GenerateEphemeralPrivateKey | ( | RandomNumberGenerator & | rng,
|  | byte * | privateKey |
| ) |  |  | const`[inline, virtual]`

generate ephemeral private key

Precondition:
  size of privateKey == PrivateEphemeralKeyLength()

Implements AuthenticatedKeyAgreementDomain.

Definition at line 38 of file dh2.h.

void DH2::GenerateEphemeralPublicKey | ( | RandomNumberGenerator & | rng,
|  | const byte * | privateKey,
|  | byte * | publicKey |
| ) |  |  | const`[inline, virtual]`

generate ephemeral public key

Precondition:
  size of publicKey == PublicEphemeralKeyLength()

Implements AuthenticatedKeyAgreementDomain.

Definition at line 40 of file dh2.h.

void DH2::GenerateEphemeralKeyPair | ( | RandomNumberGenerator & | rng,
|  | byte * | privateKey,
|  | byte * | publicKey |
| ) |  |  | const`[inline, virtual]`

generate private/public key pair

Note:
  equivalent to calling GenerateEphemeralPrivateKey() and then GenerateEphemeralPublicKey()

Reimplemented from AuthenticatedKeyAgreementDomain.

Definition at line 42 of file dh2.h.

bool DH2::Agree | ( | byte * | agreedValue,
|  | const byte * | staticPrivateKey,
|  | const byte * | ephemeralPrivateKey,
|  | const byte * | staticOtherPublicKey,
|  | const byte * | ephemeralOtherPublicKey,
|  | bool | validateStaticOtherPublicKey = `true` |
| ) |  |  | const`[virtual]`

derive agreed value from your private keys and couterparty's public keys, return false in case of failure

Note:
  The ephemeral public key will always be validated. If you have previously validated the static public key, use validateStaticOtherPublicKey=false to save time.

Precondition:
  size of agreedValue == AgreedValueLength()

  length of staticPrivateKey == StaticPrivateKeyLength()

  length of ephemeralPrivateKey == EphemeralPrivateKeyLength()

  length of staticOtherPublicKey == StaticPublicKeyLength()

  length of ephemeralOtherPublicKey == EphemeralPublicKeyLength()

Implements AuthenticatedKeyAgreementDomain.

Definition at line 8 of file dh2.cpp.

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

- dh2.h
- dh2.cpp