9 NAMESPACE_BEGIN(CryptoPP)
12 : m_p(p), m_q(q), m_g(g)
18 XTR_FindPrimesAndGenerator(rng, m_p, m_q, m_g, pbits, qbits);
26 m_g.c1.BERDecode(seq);
27 m_g.c2.BERDecode(seq);
47 pass = pass && !(m_g.c1.IsNegative() || m_g.c2.IsNegative() || m_g.c1 >= m_p || m_g.c2 >= m_p || m_g == three);
49 pass = pass && ((m_p.Squared()-m_p+1)%m_q).IsZero();
52 pass = pass && VerifyPrime(rng, m_p, level-2) && VerifyPrime(rng, m_q, level-2);
53 pass = pass && XTR_Exponentiate(m_g, (m_p.Squared()-m_p+1)/m_q, m_p) != three;
54 pass = pass && XTR_Exponentiate(m_g, m_q, m_p) == three;
61 return GetValueHelper(
this, name, valueType, pValue).Assignable()
62 CRYPTOPP_GET_FUNCTION_ENTRY(Modulus)
63 CRYPTOPP_GET_FUNCTION_ENTRY(SubgroupOrder)
64 CRYPTOPP_GET_FUNCTION_ENTRY(SubgroupGenerator)
70 AssignFromHelper(
this, source)
71 CRYPTOPP_SET_FUNCTION_ENTRY(Modulus)
72 CRYPTOPP_SET_FUNCTION_ENTRY(SubgroupOrder)
73 CRYPTOPP_SET_FUNCTION_ENTRY(SubgroupGenerator)
90 bool XTR_DH::Agree(byte *agreedValue,
const byte *privateKey,
const byte *otherPublicKey,
bool validateOtherPublicKey)
const
93 if (validateOtherPublicKey)
97 if (w.c1.IsNegative() || w.c2.IsNegative() || w.c1 >= m_p || w.c2 >= m_p || w == three)
99 if (XTR_Exponentiate(w, m_q, m_p) != three)
unsigned int PublicKeyLength() const
return length of public keys in this domain
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
bool Validate(RandomNumberGenerator &rng, unsigned int level) const
check this object for errors
interface for random number generators
static const Integer & One()
avoid calling constructors for these frequently used integers
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 failu...
void GeneratePublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
generate public key
void GeneratePrivateKey(RandomNumberGenerator &rng, byte *privateKey) const
generate private key
XTR-DH with key validation.
unsigned int AgreedValueLength() const
return length of agreed value produced
multiple precision integer and basic arithmetics
void Encode(byte *output, size_t outputLen, Signedness=UNSIGNED) const
encode in big-endian format
void DEREncode(BufferedTransformation &bt) const
encode using Distinguished Encoding Rules, put result into a BufferedTransformation object ...
"The XTR public key system" by Arjen K.
static const Integer & Zero()
avoid calling constructors for these frequently used integers
GF(p^2), optimal normal basis.
unsigned int PrivateKeyLength() const
return length of private keys in this domain
interface for retrieving values given their names