Security Scol plugin
|
Classes for Diffie-Hellman key exchange. More...
Go to the source code of this file.
Classes | |
class | DH_Domain< GROUP_PARAMETERS, COFACTOR_OPTION > |
Diffie-Hellman domain. More... | |
Typedefs | |
typedef DH_Domain< DL_GroupParameters_GFP_DefaultSafePrime > | DH |
Diffie-Hellman in GF(p) | |
Variables | |
CRYPTOPP_DLL_TEMPLATE_CLASS | DH_Domain< DL_GroupParameters_GFP_DefaultSafePrime > |
Classes for Diffie-Hellman key exchange.
Definition in file dh.h.
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
CRYPTOPP_DLL_TEMPLATE_CLASS DH_Domain< DL_GroupParameters_GFP_DefaultSafePrime > |