Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

blumshub.h

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 //! BlumBlumShub without factorization of the modulus
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 
00021         void ProcessData(byte *outString, const byte *inString, unsigned int length)
00022         {
00023                 while (length--)
00024                         *outString++ = *inString ^ GenerateByte();
00025         }
00026 
00027         bool IsSelfInverting() const {return true;}
00028         bool IsForwardTransformation() const {return true;}
00029 
00030 protected:
00031         const ModularArithmetic modn;
00032         const word maxBits;
00033         Integer current;
00034         int bitsLeft;
00035 
00036         friend class BlumGoldwasserPublicKey;
00037         friend class BlumGoldwasserPrivateKey;
00038 };
00039 
00040 //! BlumBlumShub with factorization of the modulus
00041 class BlumBlumShub : public PublicBlumBlumShub
00042 {
00043 public:
00044         // Make sure p and q are both primes congruent to 3 mod 4 and at least 512 bits long,
00045         // seed is the secret key and should be about as big as p*q
00046         BlumBlumShub(const Integer &p, const Integer &q, const Integer &seed);
00047         
00048         bool IsRandomAccess() const {return true;}
00049         void Seek(dword index);
00050 
00051 protected:
00052         const Integer p, q;
00053         const Integer x0;
00054 };
00055 
00056 NAMESPACE_END
00057 
00058 #endif

Generated on Sun Mar 14 20:44:24 2004 for Crypto++ by doxygen 1.3.6-20040222