Security Scol plugin
dh2.h
Go to the documentation of this file.
1// dh2.h - originally written and placed in the public domain by Wei Dai
2
6
7#ifndef CRYPTOPP_DH2_H
8#define CRYPTOPP_DH2_H
9
10#include "cryptlib.h"
11
12NAMESPACE_BEGIN(CryptoPP)
13
14
21{
22public:
23 virtual ~DH2() {}
24
27 : d1(domain), d2(domain) {}
29 DH2(SimpleKeyAgreementDomain &staticDomain, SimpleKeyAgreementDomain &ephemeralDomain)
30 : d1(staticDomain), d2(ephemeralDomain) {}
31
32 CryptoParameters & AccessCryptoParameters() {return d1.AccessCryptoParameters();}
33
34 unsigned int AgreedValueLength() const
35 {return d1.AgreedValueLength() + d2.AgreedValueLength();}
36
37 unsigned int StaticPrivateKeyLength() const
38 {return d1.PrivateKeyLength();}
39 unsigned int StaticPublicKeyLength() const
40 {return d1.PublicKeyLength();}
41 void GenerateStaticPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const
42 {d1.GeneratePrivateKey(rng, privateKey);}
43 void GenerateStaticPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
44 {d1.GeneratePublicKey(rng, privateKey, publicKey);}
45 void GenerateStaticKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
46 {d1.GenerateKeyPair(rng, privateKey, publicKey);}
47
48 unsigned int EphemeralPrivateKeyLength() const
49 {return d2.PrivateKeyLength();}
50 unsigned int EphemeralPublicKeyLength() const
51 {return d2.PublicKeyLength();}
52 void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const
53 {d2.GeneratePrivateKey(rng, privateKey);}
54 void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
55 {d2.GeneratePublicKey(rng, privateKey, publicKey);}
56 void GenerateEphemeralKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
57 {d2.GenerateKeyPair(rng, privateKey, publicKey);}
58
59 bool Agree(byte *agreedValue,
60 const byte *staticPrivateKey, const byte *ephemeralPrivateKey,
61 const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey,
62 bool validateStaticOtherPublicKey=true) const;
63
64protected:
66};
67
68NAMESPACE_END
69
70#endif
Interface for domains of authenticated key agreement protocols.
Definition cryptlib.h:3072
Interface for crypto parameters.
Definition cryptlib.h:2546
Unified Diffie-Hellman in GF(p)
Definition dh2.h:21
void GenerateStaticPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
Generate a static public key from a private key in this domain.
Definition dh2.h:43
DH2(SimpleKeyAgreementDomain &staticDomain, SimpleKeyAgreementDomain &ephemeralDomain)
Construct a DH2.
Definition dh2.h:29
unsigned int AgreedValueLength() const
Provides the size of the agreed value.
Definition dh2.h:34
unsigned int StaticPrivateKeyLength() const
Provides the size of the static private key.
Definition dh2.h:37
unsigned int EphemeralPrivateKeyLength() const
Provides the size of ephemeral private key.
Definition dh2.h:48
unsigned int EphemeralPublicKeyLength() const
Provides the size of ephemeral public key.
Definition dh2.h:50
void GenerateEphemeralKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
Generate private/public key pair.
Definition dh2.h:56
void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const
Generate ephemeral private key.
Definition dh2.h:52
void GenerateStaticPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const
Generate static private key in this domain.
Definition dh2.h:41
void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
Generate ephemeral public key.
Definition dh2.h:54
unsigned int StaticPublicKeyLength() const
Provides the size of the static public key.
Definition dh2.h:39
void GenerateStaticKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
Generate a static private/public key pair.
Definition dh2.h:45
DH2(SimpleKeyAgreementDomain &domain)
Construct a DH2.
Definition dh2.h:26
CryptoParameters & AccessCryptoParameters()
Retrieves a reference to Crypto Parameters.
Definition dh2.h:32
Interface for random number generators.
Definition cryptlib.h:1435
Interface for domains of simple key agreement protocols.
Definition cryptlib.h:3013
Abstract base classes that provide a uniform interface to this library.