00001
#ifndef CRYPTOPP_DH2_H
00002
#define CRYPTOPP_DH2_H
00003
00004
00005
00006
00007
#include "cryptlib.h"
00008
00009 NAMESPACE_BEGIN(CryptoPP)
00010
00011
00012 class
DH2 : public
AuthenticatedKeyAgreementDomain
00013 {
00014
public:
00015
DH2(
const SimpleKeyAgreementDomain &domain)
00016 : d1(domain), d2(domain) {}
00017
DH2(
const SimpleKeyAgreementDomain &staticDomain,
const SimpleKeyAgreementDomain &ephemeralDomain)
00018 : d1(staticDomain), d2(ephemeralDomain) {}
00019
00020 unsigned int AgreedValueLength()
const
00021
{
return d1.AgreedValueLength() + d2.AgreedValueLength();}
00022
00023 unsigned int StaticPrivateKeyLength()
const
00024
{
return d1.PrivateKeyLength();}
00025 unsigned int StaticPublicKeyLength()
const
00026
{
return d1.PublicKeyLength();}
00027 void GenerateStaticPrivateKey(
RandomNumberGenerator &rng, byte *privateKey)
const
00028
{d1.GeneratePrivateKey(rng, privateKey);}
00029 void GenerateStaticPublicKey(
RandomNumberGenerator &rng,
const byte *privateKey, byte *publicKey)
const
00030
{d1.GeneratePublicKey(rng, privateKey, publicKey);}
00031 void GenerateStaticKeyPair(
RandomNumberGenerator &rng, byte *privateKey, byte *publicKey)
const
00032
{d1.GenerateKeyPair(rng, privateKey, publicKey);}
00033
00034 unsigned int EphemeralPrivateKeyLength()
const
00035
{
return d2.PrivateKeyLength();}
00036 unsigned int EphemeralPublicKeyLength()
const
00037
{
return d2.PublicKeyLength();}
00038 void GenerateEphemeralPrivateKey(
RandomNumberGenerator &rng, byte *privateKey)
const
00039
{d2.GeneratePrivateKey(rng, privateKey);}
00040 void GenerateEphemeralPublicKey(
RandomNumberGenerator &rng,
const byte *privateKey, byte *publicKey)
const
00041
{d2.GeneratePublicKey(rng, privateKey, publicKey);}
00042 void GenerateEphemeralKeyPair(
RandomNumberGenerator &rng, byte *privateKey, byte *publicKey)
const
00043
{d2.GenerateKeyPair(rng, privateKey, publicKey);}
00044
00045
bool Agree(byte *agreedValue,
00046
const byte *staticPrivateKey,
const byte *ephemeralPrivateKey,
00047
const byte *staticOtherPublicKey,
const byte *ephemeralOtherPublicKey,
00048
bool validateStaticOtherPublicKey=
true)
const;
00049
00050
protected:
00051
const SimpleKeyAgreementDomain &d1, &d2;
00052 };
00053
00054 NAMESPACE_END
00055
00056
#endif