|
| DH () |
| Create an uninitialized Diffie-Hellman object. More...
|
|
| DH (BufferedTransformation &bt) |
| Initialize a Diffie-Hellman object. More...
|
|
| DH (const GroupParameters ¶ms) |
| Initialize a Diffie-Hellman object. More...
|
|
| DH (RandomNumberGenerator &rng, unsigned int modulusBits) |
| Create a Diffie-Hellman object. More...
|
|
| DH (const Integer &p, const Integer &g) |
| Initialize a Diffie-Hellman object. More...
|
|
| DH (const Integer &p, const Integer &q, const Integer &g) |
| Initialize a Diffie-Hellman object. More...
|
|
void | Initialize (RandomNumberGenerator &rng, unsigned int modulusBits) |
| Creates a Diffie-Hellman object. More...
|
|
void | Initialize (const Integer &p, const Integer &g) |
| Initialize a Diffie-Hellman object. More...
|
|
void | Initialize (const Integer &p, const Integer &q, const Integer &g) |
| Initialize a Diffie-Hellman object. More...
|
|
Public Member Functions inherited from DH_Domain< DL_GroupParameters_GFP_DefaultSafePrime > |
| DH_Domain () |
| Construct a Diffie-Hellman domain. More...
|
|
| DH_Domain (const GroupParameters ¶ms) |
| Construct a Diffie-Hellman domain. More...
|
|
| DH_Domain (BufferedTransformation &bt) |
| Construct a Diffie-Hellman domain. More...
|
|
| DH_Domain (RandomNumberGenerator &v1, const T2 &v2) |
| Create a Diffie-Hellman domain. More...
|
|
| DH_Domain (RandomNumberGenerator &v1, const T2 &v2, const T3 &v3) |
| Create a Diffie-Hellman domain. More...
|
|
| DH_Domain (RandomNumberGenerator &v1, const T2 &v2, const T3 &v3, const T4 &v4) |
| Create a Diffie-Hellman domain. More...
|
|
| DH_Domain (const T1 &v1, const T2 &v2) |
| Construct a Diffie-Hellman domain. More...
|
|
| DH_Domain (const T1 &v1, const T2 &v2, const T3 &v3) |
| Construct a Diffie-Hellman domain. More...
|
|
| DH_Domain (const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4) |
| Construct a Diffie-Hellman domain. More...
|
|
const GroupParameters & | GetGroupParameters () const |
| Retrieves the group parameters for this domain. More...
|
|
GroupParameters & | AccessGroupParameters () |
| Retrieves the group parameters for this domain. More...
|
|
void | GeneratePublicKey (RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const |
| Generate a public key from a private key in this domain. More...
|
|
std::string | AlgorithmName () const |
| Provides the name of this algorithm. More...
|
|
Public Member Functions inherited from DL_SimpleKeyAgreementDomainBase< GROUP_PARAMETERS::Element > |
CryptoParameters & | AccessCryptoParameters () |
| Retrieves a reference to Crypto Parameters. More...
|
|
unsigned int | AgreedValueLength () const |
| Provides the size of the agreed value. More...
|
|
unsigned int | PrivateKeyLength () const |
| Provides the size of the private key. More...
|
|
unsigned int | PublicKeyLength () const |
| Provides the size of the public key. More...
|
|
void | GeneratePrivateKey (RandomNumberGenerator &rng, byte *privateKey) const |
| Generate private key in this domain. More...
|
|
void | GeneratePublicKey (RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const |
| Generate a public key from a private key in this domain. More...
|
|
bool | Agree (byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const |
| Derive agreed value. More...
|
|
const Element & | GetGenerator () const |
| Retrieves a reference to the group generator. More...
|
|
Public Member Functions inherited from SimpleKeyAgreementDomain |
virtual unsigned int | AgreedValueLength () const =0 |
| Provides the size of the agreed value. More...
|
|
virtual unsigned int | PrivateKeyLength () const =0 |
| Provides the size of the private key. More...
|
|
virtual unsigned int | PublicKeyLength () const =0 |
| Provides the size of the public key. More...
|
|
virtual void | GeneratePrivateKey (RandomNumberGenerator &rng, byte *privateKey) const =0 |
| Generate private key in this domain. More...
|
|
virtual void | GeneratePublicKey (RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const =0 |
| Generate a public key from a private key in this domain. More...
|
|
virtual void | GenerateKeyPair (RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const |
| Generate a private/public key pair. More...
|
|
virtual bool | Agree (byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const =0 |
| Derive agreed value. More...
|
|
CryptoMaterial & | AccessMaterial () |
| Retrieves a reference to Crypto Parameters. More...
|
|
const CryptoMaterial & | GetMaterial () const |
| Retrieves a reference to Crypto Parameters. More...
|
|
virtual CryptoParameters & | AccessCryptoParameters ()=0 |
| Retrieves a reference to Crypto Parameters. More...
|
|
virtual const CryptoParameters & | GetCryptoParameters () const |
| Retrieves a reference to Crypto Parameters. More...
|
|
virtual CryptoMaterial & | AccessMaterial ()=0 |
| Retrieves a reference to CryptoMaterial. More...
|
|
virtual const CryptoMaterial & | GetMaterial () const =0 |
| Retrieves a reference to CryptoMaterial. More...
|
|
| Algorithm (bool checkSelfTestStatus=true) |
| Interface for all crypto algorithms. More...
|
|
virtual std::string | AlgorithmName () const |
| Provides the name of this algorithm. More...
|
|
virtual std::string | AlgorithmProvider () const |
| Retrieve the provider of this algorithm. More...
|
|
virtual Clonable * | Clone () const |
| Copies this object. More...
|
|
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.