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, size_t 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         ModularArithmetic modn;
00032         word maxBits, bitsLeft;
00033         Integer current;
00034 
00035         friend class BlumGoldwasserPublicKey;
00036         friend class BlumGoldwasserPrivateKey;
00037 };
00038 
00039 //! BlumBlumShub with factorization of the modulus
00040 class BlumBlumShub : public PublicBlumBlumShub
00041 {
00042 public:
00043         // Make sure p and q are both primes congruent to 3 mod 4 and at least 512 bits long,
00044         // seed is the secret key and should be about as big as p*q
00045         BlumBlumShub(const Integer &p, const Integer &q, const Integer &seed);
00046         
00047         bool IsRandomAccess() const {return true;}
00048         void Seek(lword index);
00049 
00050 protected:
00051         const Integer p, q;
00052         const Integer x0;
00053 };
00054 
00055 NAMESPACE_END
00056 
00057 #endif

Generated on Sat Dec 23 02:07:06 2006 for Crypto++ by  doxygen 1.5.1-p1