XTR_DH Class Reference

#include <xtrcrypt.h>

Inheritance diagram for XTR_DH:

SimpleKeyAgreementDomain CryptoParameters KeyAgreementAlgorithm GeneratableCryptoMaterial AsymmetricAlgorithm CryptoMaterial Algorithm NameValuePairs Clonable List of all members.

Detailed Description

XTR-DH with key validation.

Definition at line 14 of file xtrcrypt.h.

Public Member Functions

 XTR_DH (const Integer &p, const Integer &q, const GFP2Element &g)
 XTR_DH (RandomNumberGenerator &rng, unsigned int pbits, unsigned int qbits)
 XTR_DH (BufferedTransformation &domainParams)
void DEREncode (BufferedTransformation &domainParams) const
 for backwards compatibility, calls GetMaterial().Save(bt)
bool Validate (RandomNumberGenerator &rng, unsigned int level) const
 check this object for errors
bool GetVoidValue (const char *name, const std::type_info &valueType, void *pValue) const
 to be implemented by derived classes, users should use one of the above functions instead
void AssignFrom (const NameValuePairs &source)
 assign values from source to this object
CryptoParametersAccessCryptoParameters ()
unsigned int AgreedValueLength () const
 return length of agreed value produced
unsigned int PrivateKeyLength () const
 return length of private keys in this domain
unsigned int PublicKeyLength () const
 return length of public keys in this domain
void GeneratePrivateKey (RandomNumberGenerator &rng, byte *privateKey) const
 generate private key
void GeneratePublicKey (RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
 generate public key
bool Agree (byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const
 derive agreed value from your private key and couterparty's public key, return false in case of failure
const IntegerGetModulus () const
const IntegerGetSubgroupOrder () const
const GFP2ElementGetSubgroupGenerator () const
void SetModulus (const Integer &p)
void SetSubgroupOrder (const Integer &q)
void SetSubgroupGenerator (const GFP2Element &g)
virtual void GenerateKeyPair (RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
 generate private/public key pair
CryptoMaterialAccessMaterial ()
 returns a reference to the crypto material used by this object
const CryptoMaterialGetMaterial () const
 returns a const reference to the crypto material used by this object
virtual const CryptoParametersGetCryptoParameters () const
void BERDecode (BufferedTransformation &bt)
 for backwards compatibility, calls AccessMaterial().Load(bt)
virtual std::string AlgorithmName () const
 returns name of this algorithm, not universally implemented yet
virtual ClonableClone () const
 this is not implemented by most classes yet


Member Function Documentation

bool XTR_DH::Validate ( RandomNumberGenerator rng,
unsigned int  level 
) const [virtual]

check this object for errors

Parameters:
level denotes the level of thoroughness: 0 - using this object won't cause a crash or exception (rng is ignored) 1 - this object will probably function (encrypt, sign, etc.) correctly (but may not check for weak keys and such) 2 - make sure this object will function correctly, and do reasonable security checks 3 - do checks that may take a long time
Returns:
true if the tests pass

Implements CryptoMaterial.

Definition at line 41 of file xtrcrypt.cpp.

References GFP2Element::c1, GFP2Element::c2, Integer::IsNegative(), Integer::IsOdd(), Integer::One(), and Integer::Squared().

void XTR_DH::AssignFrom ( const NameValuePairs source  )  [virtual]

assign values from source to this object

Note:
This function can be used to create a public key from a private key.

Implements CryptoMaterial.

Definition at line 68 of file xtrcrypt.cpp.

void XTR_DH::GeneratePrivateKey ( RandomNumberGenerator rng,
byte *  privateKey 
) const [virtual]

generate private key

Precondition:
size of privateKey == PrivateKeyLength()

Implements SimpleKeyAgreementDomain.

Definition at line 77 of file xtrcrypt.cpp.

References Integer::Encode(), PrivateKeyLength(), and Integer::Zero().

void XTR_DH::GeneratePublicKey ( RandomNumberGenerator rng,
const byte *  privateKey,
byte *  publicKey 
) const [virtual]

generate public key

Precondition:
size of publicKey == PublicKeyLength()

Implements SimpleKeyAgreementDomain.

Definition at line 83 of file xtrcrypt.cpp.

References GFP2Element::Encode(), PrivateKeyLength(), and PublicKeyLength().

bool XTR_DH::Agree ( byte *  agreedValue,
const byte *  privateKey,
const byte *  otherPublicKey,
bool  validateOtherPublicKey = true 
) const [virtual]

derive agreed value from your private key and couterparty's public key, return false in case of failure

Note:
If you have previously validated the public key, use validateOtherPublicKey=false to save time.
Precondition:
size of agreedValue == AgreedValueLength()

length of privateKey == PrivateKeyLength()

length of otherPublicKey == PublicKeyLength()

Implements SimpleKeyAgreementDomain.

Definition at line 90 of file xtrcrypt.cpp.

References AgreedValueLength(), GFP2Element::c1, GFP2Element::c2, GFP2_ONB< F >::ConvertIn(), GFP2Element::Encode(), Integer::IsNegative(), PrivateKeyLength(), and PublicKeyLength().

void SimpleKeyAgreementDomain::GenerateKeyPair ( RandomNumberGenerator rng,
byte *  privateKey,
byte *  publicKey 
) const [virtual, inherited]

generate private/public key pair

Note:
equivalent to calling GeneratePrivateKey() and then GeneratePublicKey()

Definition at line 675 of file cryptlib.cpp.

References SimpleKeyAgreementDomain::GeneratePrivateKey(), and SimpleKeyAgreementDomain::GeneratePublicKey().


The documentation for this class was generated from the following files:
Generated on Sat Dec 23 02:07:38 2006 for Crypto++ by  doxygen 1.5.1-p1