ext-cryptopp/blumshub.h

50 lines
1.2 KiB
C
Raw Normal View History

2002-10-04 17:31:41 +00:00
#ifndef CRYPTOPP_BLUMSHUB_H
#define CRYPTOPP_BLUMSHUB_H
#include "config.h"
#include "integer.h"
2002-10-04 17:31:41 +00:00
#include "modarith.h"
NAMESPACE_BEGIN(CryptoPP)
//! BlumBlumShub without factorization of the modulus
class PublicBlumBlumShub : public RandomNumberGenerator,
public StreamTransformation
{
public:
PublicBlumBlumShub(const Integer &n, const Integer &seed);
unsigned int GenerateBit();
byte GenerateByte();
void GenerateBlock(byte *output, size_t size);
void ProcessData(byte *outString, const byte *inString, size_t length);
2002-10-04 17:31:41 +00:00
bool IsSelfInverting() const {return true;}
bool IsForwardTransformation() const {return true;}
protected:
2006-03-13 13:26:41 +00:00
ModularArithmetic modn;
word maxBits, bitsLeft;
2002-10-04 17:31:41 +00:00
Integer current;
};
//! BlumBlumShub with factorization of the modulus
class BlumBlumShub : public PublicBlumBlumShub
{
public:
// Make sure p and q are both primes congruent to 3 mod 4 and at least 512 bits long,
// seed is the secret key and should be about as big as p*q
BlumBlumShub(const Integer &p, const Integer &q, const Integer &seed);
bool IsRandomAccess() const {return true;}
2003-07-25 00:15:52 +00:00
void Seek(lword index);
2002-10-04 17:31:41 +00:00
protected:
const Integer p, q;
const Integer x0;
};
NAMESPACE_END
#endif