|
| DH () |
| Create an uninitialized Diffie-Hellman object.
|
|
| DH (BufferedTransformation &bt) |
| Initialize a Diffie-Hellman object.
|
|
| DH (const GroupParameters ¶ms) |
| Initialize a Diffie-Hellman object.
|
|
| DH (RandomNumberGenerator &rng, unsigned int modulusBits) |
| Create a Diffie-Hellman object.
|
|
| DH (const Integer &p, const Integer &g) |
| Initialize a Diffie-Hellman object.
|
|
| DH (const Integer &p, const Integer &q, const Integer &g) |
| Initialize a Diffie-Hellman object.
|
|
void | Initialize (RandomNumberGenerator &rng, unsigned int modulusBits) |
| Creates a Diffie-Hellman object.
|
|
void | Initialize (const Integer &p, const Integer &g) |
| Initialize a Diffie-Hellman object.
|
|
void | Initialize (const Integer &p, const Integer &q, const Integer &g) |
| Initialize a Diffie-Hellman object.
|
|
Public Member Functions inherited from DH_Domain< DL_GroupParameters_GFP_DefaultSafePrime > |
| DH_Domain () |
| Construct a Diffie-Hellman domain.
|
|
| DH_Domain (const GroupParameters ¶ms) |
| Construct a Diffie-Hellman domain.
|
|
| DH_Domain (BufferedTransformation &bt) |
| Construct a Diffie-Hellman domain.
|
|
| DH_Domain (RandomNumberGenerator &v1, const T2 &v2) |
| Create a Diffie-Hellman domain.
|
|
| DH_Domain (RandomNumberGenerator &v1, const T2 &v2, const T3 &v3) |
| Create a Diffie-Hellman domain.
|
|
| DH_Domain (RandomNumberGenerator &v1, const T2 &v2, const T3 &v3, const T4 &v4) |
| Create a Diffie-Hellman domain.
|
|
| DH_Domain (const T1 &v1, const T2 &v2) |
| Construct a Diffie-Hellman domain.
|
|
| DH_Domain (const T1 &v1, const T2 &v2, const T3 &v3) |
| Construct a Diffie-Hellman domain.
|
|
| DH_Domain (const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4) |
| Construct a Diffie-Hellman domain.
|
|
const GroupParameters & | GetGroupParameters () const |
| Retrieves the group parameters for this domain.
|
|
GroupParameters & | AccessGroupParameters () |
| Retrieves the group parameters for this domain.
|
|
void | GeneratePublicKey (RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const |
| Generate a public key from a private key in this domain.
|
|
std::string | AlgorithmName () const |
| Provides the name of this algorithm.
|
|
Public Member Functions inherited from DL_SimpleKeyAgreementDomainBase< GROUP_PARAMETERS::Element > |
CryptoParameters & | AccessCryptoParameters () |
| Retrieves a reference to Crypto Parameters.
|
|
unsigned int | AgreedValueLength () const |
| Provides the size of the agreed value.
|
|
unsigned int | PrivateKeyLength () const |
| Provides the size of the private key.
|
|
unsigned int | PublicKeyLength () const |
| Provides the size of the public key.
|
|
void | GeneratePrivateKey (RandomNumberGenerator &rng, byte *privateKey) const |
| Generate private key in this domain.
|
|
void | GeneratePublicKey (RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const |
| Generate a public key from a private key in this domain.
|
|
bool | Agree (byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const |
| Derive agreed value.
|
|
const Element & | GetGenerator () const |
| Retrieves a reference to the group generator.
|
|
Public Member Functions inherited from SimpleKeyAgreementDomain |
virtual void | GenerateKeyPair (RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const |
| Generate a private/public key pair.
|
|
CryptoMaterial & | AccessMaterial () |
| Retrieves a reference to Crypto Parameters.
|
|
const CryptoMaterial & | GetMaterial () const |
| Retrieves a reference to Crypto Parameters.
|
|
virtual const CryptoParameters & | GetCryptoParameters () const |
| Retrieves a reference to Crypto Parameters.
|
|
| Algorithm (bool checkSelfTestStatus=true) |
| Interface for all crypto algorithms.
|
|
virtual std::string | AlgorithmProvider () const |
| Retrieve the provider of this algorithm.
|
|
virtual Clonable * | Clone () const |
| Copies this object.
|
|
Diffie-Hellman in GF(p)
DH() class is a typedef of DH_Domain(). The documentation that follows does not exist. Rather the documentation was created in response to Issue 328, Diffie-Hellman example code not compiling.
Generally speaking, a DH() object is ephemeral and is intended to execute one instance of the Diffie-Hellman protocol. The private and public key parts are not intended to be set or persisted. Rather, a new set of domain parameters are generated each time an object is created.
Once a DH() object is created, once can retrieve the ephemeral public key for the other party with code similar to the following.
AutoSeededRandomPool prng;
Integer p, q, g;
PrimeAndGenerator pg;
pg.Generate(1, prng, 512, 511);
p = pg.Prime();
q = pg.SubPrime();
g = pg.Generator();
DH dh(p, q, g);
SecByteBlock t1(dh.PrivateKeyLength()), t2(dh.PublicKeyLength());
dh.GenerateKeyPair(prng, t1, t2);
Integer k1(t1, t1.size()), k2(t2, t2.size());
cout << "Private key:\n";
cout << hex << k1 << endl;
cout << "Public key:\n";
cout << hex << k2 << endl;
Output of the program above will be similar to the following.
$ ./cryptest.exe
Private key:
72b45a42371545e9d4880f48589aefh
Public key:
45fdb13f97b1840626f0250cec1dba4a23b894100b51fb5d2dd13693d789948f8bfc88f9200014b2
ba8dd8a6debc471c69ef1e2326c61184a2eca88ec866346bh
- See also
- Diffie-Hellman on the Crypto++ wiki and Diffie-Hellman in GF(p) with key validation
- Since
- Crypto++ 1.0
Definition at line 211 of file dh.h.