Fabcoin Core  0.16.2
P2P Digital Currency
Public Member Functions | Protected Attributes | List of all members
DH2 Class Reference

Unified Diffie-Hellman in GF(p) More...

#include <dh2.h>

Inheritance diagram for DH2:
[legend]
Collaboration diagram for DH2:
[legend]

Public Member Functions

virtual ~DH2 ()
 
 DH2 (SimpleKeyAgreementDomain &domain)
 Construct a DH2. More...
 
 DH2 (SimpleKeyAgreementDomain &staticDomain, SimpleKeyAgreementDomain &ephemeralDomain)
 Construct a DH2. More...
 
CryptoParametersAccessCryptoParameters ()
 Retrieves a reference to Crypto Parameters. More...
 
unsigned int AgreedValueLength () const
 Provides the size of the agreed value. More...
 
unsigned int StaticPrivateKeyLength () const
 Provides the size of the static private key. More...
 
unsigned int StaticPublicKeyLength () const
 Provides the size of the static public key. More...
 
void GenerateStaticPrivateKey (RandomNumberGenerator &rng, byte *privateKey) const
 Generate static private key in this domain. More...
 
void GenerateStaticPublicKey (RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
 Generate a static public key from a private key in this domain. More...
 
void GenerateStaticKeyPair (RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
 Generate a static private/public key pair. More...
 
unsigned int EphemeralPrivateKeyLength () const
 Provides the size of ephemeral private key. More...
 
unsigned int EphemeralPublicKeyLength () const
 Provides the size of ephemeral public key. More...
 
void GenerateEphemeralPrivateKey (RandomNumberGenerator &rng, byte *privateKey) const
 Generate ephemeral private key. More...
 
void GenerateEphemeralPublicKey (RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
 Generate ephemeral public key. More...
 
void GenerateEphemeralKeyPair (RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
 Generate private/public key pair. More...
 
bool Agree (byte *agreedValue, const byte *staticPrivateKey, const byte *ephemeralPrivateKey, const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey, bool validateStaticOtherPublicKey=true) const
 Derive agreed value. More...
 
- Public Member Functions inherited from AuthenticatedKeyAgreementDomain
virtual ~AuthenticatedKeyAgreementDomain ()
 
- Public Member Functions inherited from KeyAgreementAlgorithm
virtual ~KeyAgreementAlgorithm ()
 
CryptoMaterialAccessMaterial ()
 Retrieves a reference to Crypto Parameters. More...
 
const CryptoMaterialGetMaterial () const
 Retrieves a reference to Crypto Parameters. More...
 
virtual const CryptoParametersGetCryptoParameters () const
 Retrieves a reference to Crypto Parameters. More...
 
- Public Member Functions inherited from AsymmetricAlgorithm
virtual ~AsymmetricAlgorithm ()
 
void BERDecode (BufferedTransformation &bt)
 Loads this object from a BufferedTransformation. More...
 
void DEREncode (BufferedTransformation &bt) const
 Saves this object to a BufferedTransformation. More...
 
- Public Member Functions inherited from Algorithm
virtual ~Algorithm ()
 
 Algorithm (bool checkSelfTestStatus=true)
 Interface for all crypto algorithms. More...
 
virtual std::string AlgorithmName () const
 Provides the name of this algorithm. More...
 
- Public Member Functions inherited from Clonable
virtual ~Clonable ()
 
virtual ClonableClone () const
 Copies this object. More...
 

Protected Attributes

SimpleKeyAgreementDomaind1
 
SimpleKeyAgreementDomaind2
 

Detailed Description

Unified Diffie-Hellman in GF(p)

A Diffie-Hellman domain is a set of parameters that must be shared by two parties in a key agreement protocol, along with the algorithms for generating key pairs and deriving agreed values.

See also
AuthenticatedKeyAgreementDomain, Unified Diffie-Hellman
Since
Crypto++ 1.0

Definition at line 20 of file dh2.h.

Constructor & Destructor Documentation

virtual DH2::~DH2 ( )
inlinevirtual

Definition at line 23 of file dh2.h.

DH2::DH2 ( SimpleKeyAgreementDomain domain)
inline

Construct a DH2.

Definition at line 26 of file dh2.h.

DH2::DH2 ( SimpleKeyAgreementDomain staticDomain,
SimpleKeyAgreementDomain ephemeralDomain 
)
inline

Construct a DH2.

Definition at line 29 of file dh2.h.

Member Function Documentation

CryptoParameters& DH2::AccessCryptoParameters ( )
inlinevirtual

Retrieves a reference to Crypto Parameters.

Returns
a reference the crypto parameters

Implements KeyAgreementAlgorithm.

Definition at line 32 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.

Parameters
agreedValuea byte buffer for the shared secret
staticPrivateKeya byte buffer with your static private key in this domain
ephemeralPrivateKeya byte buffer with your ephemeral private key in this domain
staticOtherPublicKeya byte buffer with the other party's static public key in this domain
ephemeralOtherPublicKeya byte buffer with the other party's ephemeral public key in this domain
validateStaticOtherPublicKeya flag indicating if the other party's public key should be validated
Returns
true upon success, false in case of failure

Agree() derives an agreed value from your private keys and couterparty's public keys.

The other party's ephemeral public key is validated by default. If you have previously validated the static public key, use validateStaticOtherPublicKey=false to save time.

Precondition
COUNTOF(agreedValue) == AgreedValueLength()
COUNTOF(staticPrivateKey) == StaticPrivateKeyLength()
COUNTOF(ephemeralPrivateKey) == EphemeralPrivateKeyLength()
COUNTOF(staticOtherPublicKey) == StaticPublicKeyLength()
COUNTOF(ephemeralOtherPublicKey) == EphemeralPublicKeyLength()

Implements AuthenticatedKeyAgreementDomain.

Definition at line 15 of file dh2.cpp.

Here is the call graph for this function:

unsigned int DH2::AgreedValueLength ( ) const
inlinevirtual

Provides the size of the agreed value.

Returns
size of agreed value produced in this domain

Implements AuthenticatedKeyAgreementDomain.

Definition at line 34 of file dh2.h.

unsigned int DH2::EphemeralPrivateKeyLength ( ) const
inlinevirtual

Provides the size of ephemeral private key.

Returns
the size of ephemeral private key in this domain

Implements AuthenticatedKeyAgreementDomain.

Definition at line 48 of file dh2.h.

unsigned int DH2::EphemeralPublicKeyLength ( ) const
inlinevirtual

Provides the size of ephemeral public key.

Returns
the size of ephemeral public key in this domain

Implements AuthenticatedKeyAgreementDomain.

Definition at line 50 of file dh2.h.

void DH2::GenerateEphemeralKeyPair ( RandomNumberGenerator rng,
byte privateKey,
byte publicKey 
) const
inlinevirtual

Generate private/public key pair.

Parameters
rnga RandomNumberGenerator derived class
privateKeya byte buffer for the generated private key in this domain
publicKeya byte buffer for the generated public key in this domain

GenerateEphemeralKeyPair() is equivalent to calling GenerateEphemeralPrivateKey() and then GenerateEphemeralPublicKey()

Reimplemented from AuthenticatedKeyAgreementDomain.

Definition at line 56 of file dh2.h.

void DH2::GenerateEphemeralPrivateKey ( RandomNumberGenerator rng,
byte privateKey 
) const
inlinevirtual

Generate ephemeral private key.

Parameters
rnga RandomNumberGenerator derived class
privateKeya byte buffer for the generated private key in this domain
Precondition
COUNTOF(privateKey) == PrivateEphemeralKeyLength()

Implements AuthenticatedKeyAgreementDomain.

Definition at line 52 of file dh2.h.

void DH2::GenerateEphemeralPublicKey ( RandomNumberGenerator rng,
const byte privateKey,
byte publicKey 
) const
inlinevirtual

Generate ephemeral public key.

Parameters
rnga RandomNumberGenerator derived class
privateKeya byte buffer for the generated private key in this domain
publicKeya byte buffer for the generated public key in this domain
Precondition
COUNTOF(publicKey) == PublicEphemeralKeyLength()

Implements AuthenticatedKeyAgreementDomain.

Definition at line 54 of file dh2.h.

void DH2::GenerateStaticKeyPair ( RandomNumberGenerator rng,
byte privateKey,
byte publicKey 
) const
inlinevirtual

Generate a static private/public key pair.

Parameters
rnga RandomNumberGenerator derived class
privateKeya byte buffer for the generated private key in this domain
publicKeya byte buffer for the generated public key in this domain

GenerateStaticKeyPair() is equivalent to calling GenerateStaticPrivateKey() and then GenerateStaticPublicKey().

Precondition
COUNTOF(privateKey) == PrivateStaticKeyLength()
COUNTOF(publicKey) == PublicStaticKeyLength()

Reimplemented from AuthenticatedKeyAgreementDomain.

Definition at line 45 of file dh2.h.

void DH2::GenerateStaticPrivateKey ( RandomNumberGenerator rng,
byte privateKey 
) const
inlinevirtual

Generate static private key in this domain.

Parameters
rnga RandomNumberGenerator derived class
privateKeya byte buffer for the generated private key in this domain
Precondition
COUNTOF(privateKey) == PrivateStaticKeyLength()

Implements AuthenticatedKeyAgreementDomain.

Definition at line 41 of file dh2.h.

void DH2::GenerateStaticPublicKey ( RandomNumberGenerator rng,
const byte privateKey,
byte publicKey 
) const
inlinevirtual

Generate a static public key from a private key in this domain.

Parameters
rnga RandomNumberGenerator derived class
privateKeya byte buffer with the previously generated private key
publicKeya byte buffer for the generated public key in this domain
Precondition
COUNTOF(publicKey) == PublicStaticKeyLength()

Implements AuthenticatedKeyAgreementDomain.

Definition at line 43 of file dh2.h.

unsigned int DH2::StaticPrivateKeyLength ( ) const
inlinevirtual

Provides the size of the static private key.

Returns
size of static private keys in this domain

Implements AuthenticatedKeyAgreementDomain.

Definition at line 37 of file dh2.h.

unsigned int DH2::StaticPublicKeyLength ( ) const
inlinevirtual

Provides the size of the static public key.

Returns
size of static public keys in this domain

Implements AuthenticatedKeyAgreementDomain.

Definition at line 39 of file dh2.h.

Member Data Documentation

SimpleKeyAgreementDomain& DH2::d1
protected

Definition at line 65 of file dh2.h.

SimpleKeyAgreementDomain & DH2::d2
protected

Definition at line 65 of file dh2.h.


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