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.

53 lines
1.3 KiB

  1. #ifndef CRYPTOPP_BLUMSHUB_H
  2. #define CRYPTOPP_BLUMSHUB_H
  3. #include "modarith.h"
  4. NAMESPACE_BEGIN(CryptoPP)
  5. class BlumGoldwasserPublicKey;
  6. class BlumGoldwasserPrivateKey;
  7. //! BlumBlumShub without factorization of the modulus
  8. class PublicBlumBlumShub : public RandomNumberGenerator,
  9. public StreamTransformation
  10. {
  11. public:
  12. PublicBlumBlumShub(const Integer &n, const Integer &seed);
  13. unsigned int GenerateBit();
  14. byte GenerateByte();
  15. void GenerateBlock(byte *output, size_t size);
  16. void ProcessData(byte *outString, const byte *inString, size_t length);
  17. bool IsSelfInverting() const {return true;}
  18. bool IsForwardTransformation() const {return true;}
  19. protected:
  20. ModularArithmetic modn;
  21. word maxBits, bitsLeft;
  22. Integer current;
  23. friend class BlumGoldwasserPublicKey;
  24. friend class BlumGoldwasserPrivateKey;
  25. };
  26. //! BlumBlumShub with factorization of the modulus
  27. class BlumBlumShub : public PublicBlumBlumShub
  28. {
  29. public:
  30. // Make sure p and q are both primes congruent to 3 mod 4 and at least 512 bits long,
  31. // seed is the secret key and should be about as big as p*q
  32. BlumBlumShub(const Integer &p, const Integer &q, const Integer &seed);
  33. bool IsRandomAccess() const {return true;}
  34. void Seek(lword index);
  35. protected:
  36. const Integer p, q;
  37. const Integer x0;
  38. };
  39. NAMESPACE_END
  40. #endif