blumshub.h
#ifndef CRYPTOPP_BLUMSHUB_H
#define CRYPTOPP_BLUMSHUB_H
#include "modarith.h"
NAMESPACE_BEGIN(CryptoPP)
class BlumGoldwasserPublicKey;
class BlumGoldwasserPrivateKey;
//! 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);
bool IsSelfInverting() const {return true;}
bool IsForwardTransformation() const {return true;}
protected:
ModularArithmetic modn;
word maxBits, bitsLeft;
Integer current;
friend class BlumGoldwasserPublicKey;
friend class BlumGoldwasserPrivateKey;
};
//! 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;}
void Seek(lword index);
protected:
const Integer p, q;
const Integer x0;
};
NAMESPACE_END
#endif
PublicBlumBlumShub::IsSelfInverting
bool IsSelfInverting() const
returns whether this transformation is self-inverting (e.g. xor with a keystream) ...
Definition: blumshub.h:23
BlumBlumShub::Seek
void Seek(lword index)
for random access ciphers, seek to an absolute position
ModularArithmetic
ring of congruence classes modulo n
Definition: modarith.h:19
RandomNumberGenerator
interface for random number generators
Definition: cryptlib.h:668
PublicBlumBlumShub::IsForwardTransformation
bool IsForwardTransformation() const
returns whether this is an encryption object
Definition: blumshub.h:24
Integer
multiple precision integer and basic arithmetics
Definition: integer.h:26
StreamTransformation
interface for the data processing part of stream ciphers
Definition: cryptlib.h:469
BlumBlumShub::IsRandomAccess
bool IsRandomAccess() const
returns whether this cipher supports random access
Definition: blumshub.h:43
BlumBlumShub
BlumBlumShub with factorization of the modulus.
Definition: blumshub.h:36
PublicBlumBlumShub
BlumBlumShub without factorization of the modulus.
Definition: blumshub.h:12