File indexing completed on 2025-01-18 09:54:54
0001
0002
0003
0004
0005
0006 #ifndef CRYPTOPP_BLUMSHUB_H
0007 #define CRYPTOPP_BLUMSHUB_H
0008
0009 #include "cryptlib.h"
0010 #include "modarith.h"
0011 #include "integer.h"
0012
0013 NAMESPACE_BEGIN(CryptoPP)
0014
0015
0016
0017
0018 class PublicBlumBlumShub : public RandomNumberGenerator,
0019 public StreamTransformation
0020 {
0021 public:
0022 virtual ~PublicBlumBlumShub() {}
0023
0024
0025
0026
0027
0028 PublicBlumBlumShub(const Integer &n, const Integer &seed);
0029
0030 unsigned int GenerateBit();
0031 byte GenerateByte();
0032 void GenerateBlock(byte *output, size_t size);
0033 void ProcessData(byte *outString, const byte *inString, size_t length);
0034
0035 bool IsSelfInverting() const {return true;}
0036 bool IsForwardTransformation() const {return true;}
0037
0038 protected:
0039 ModularArithmetic modn;
0040 Integer current;
0041 word maxBits, bitsLeft;
0042 };
0043
0044
0045
0046
0047 class BlumBlumShub : public PublicBlumBlumShub
0048 {
0049 public:
0050 virtual ~BlumBlumShub() {}
0051
0052
0053
0054
0055
0056
0057
0058 BlumBlumShub(const Integer &p, const Integer &q, const Integer &seed);
0059
0060 bool IsRandomAccess() const {return true;}
0061 void Seek(lword index);
0062
0063 protected:
0064 const Integer p, q;
0065 const Integer x0;
0066 };
0067
0068 NAMESPACE_END
0069
0070 #endif