Crypto++  5.6.4
Free C++ class library of cryptographic schemes
Public Member Functions | List of all members
DH2 Class Reference

Unified Diffie-Hellman More...

+ Inheritance diagram for DH2:

Public Member Functions

 DH2 (SimpleKeyAgreementDomain &domain)
 
 DH2 (SimpleKeyAgreementDomain &staticDomain, SimpleKeyAgreementDomain &ephemeralDomain)
 
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 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
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
 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 ClonableClone () const
 Copies this object. More...
 

Detailed Description

Unified Diffie-Hellman

Definition at line 15 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 23 of file dh2.h.

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 25 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 28 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 30 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 32 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 34 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 36 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 39 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 41 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 43 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 45 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 47 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.


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