Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.8 KiB

  1. #ifndef CRYPTOPP_XTRCRYPT_H
  2. #define CRYPTOPP_XTRCRYPT_H
  3. /** \file
  4. "The XTR public key system" by Arjen K. Lenstra and Eric R. Verheul
  5. */
  6. #include "xtr.h"
  7. NAMESPACE_BEGIN(CryptoPP)
  8. //! XTR-DH with key validation
  9. class XTR_DH : public SimpleKeyAgreementDomain, public CryptoParameters
  10. {
  11. typedef XTR_DH ThisClass;
  12. public:
  13. XTR_DH(const Integer &p, const Integer &q, const GFP2Element &g);
  14. XTR_DH(RandomNumberGenerator &rng, unsigned int pbits, unsigned int qbits);
  15. XTR_DH(BufferedTransformation &domainParams);
  16. void DEREncode(BufferedTransformation &domainParams) const;
  17. bool Validate(RandomNumberGenerator &rng, unsigned int level) const;
  18. bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
  19. void AssignFrom(const NameValuePairs &source);
  20. CryptoParameters & AccessCryptoParameters() {return *this;}
  21. unsigned int AgreedValueLength() const {return 2*m_p.ByteCount();}
  22. unsigned int PrivateKeyLength() const {return m_q.ByteCount();}
  23. unsigned int PublicKeyLength() const {return 2*m_p.ByteCount();}
  24. void GeneratePrivateKey(RandomNumberGenerator &rng, byte *privateKey) const;
  25. void GeneratePublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const;
  26. bool Agree(byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const;
  27. const Integer &GetModulus() const {return m_p;}
  28. const Integer &GetSubgroupOrder() const {return m_q;}
  29. const GFP2Element &GetSubgroupGenerator() const {return m_g;}
  30. void SetModulus(const Integer &p) {m_p = p;}
  31. void SetSubgroupOrder(const Integer &q) {m_q = q;}
  32. void SetSubgroupGenerator(const GFP2Element &g) {m_g = g;}
  33. private:
  34. unsigned int ExponentBitLength() const;
  35. Integer m_p, m_q;
  36. GFP2Element m_g;
  37. };
  38. NAMESPACE_END
  39. #endif