00001 #ifndef CRYPTOPP_BLUMSHUB_H
00002 #define CRYPTOPP_BLUMSHUB_H
00003
00004 #include "modarith.h"
00005
00006 NAMESPACE_BEGIN(CryptoPP)
00007
00008 class BlumGoldwasserPublicKey;
00009 class BlumGoldwasserPrivateKey;
00010
00011
00012 class PublicBlumBlumShub : public RandomNumberGenerator,
00013 public StreamTransformation
00014 {
00015 public:
00016 PublicBlumBlumShub(const Integer &n, const Integer &seed);
00017
00018 unsigned int GenerateBit();
00019 byte GenerateByte();
00020 void GenerateBlock(byte *output, size_t size);
00021 void ProcessData(byte *outString, const byte *inString, size_t length);
00022
00023 bool IsSelfInverting() const {return true;}
00024 bool IsForwardTransformation() const {return true;}
00025
00026 protected:
00027 ModularArithmetic modn;
00028 word maxBits, bitsLeft;
00029 Integer current;
00030
00031 friend class BlumGoldwasserPublicKey;
00032 friend class BlumGoldwasserPrivateKey;
00033 };
00034
00035
00036 class BlumBlumShub : public PublicBlumBlumShub
00037 {
00038 public:
00039
00040
00041 BlumBlumShub(const Integer &p, const Integer &q, const Integer &seed);
00042
00043 bool IsRandomAccess() const {return true;}
00044 void Seek(lword index);
00045
00046 protected:
00047 const Integer p, q;
00048 const Integer x0;
00049 };
00050
00051 NAMESPACE_END
00052
00053 #endif