Crypto++
blumshub.h
1 #ifndef CRYPTOPP_BLUMSHUB_H
2 #define CRYPTOPP_BLUMSHUB_H
3 
4 #include "modarith.h"
5 
6 NAMESPACE_BEGIN(CryptoPP)
7 
8 class BlumGoldwasserPublicKey;
9 class BlumGoldwasserPrivateKey;
10 
11 //! BlumBlumShub without factorization of the modulus
14 {
15 public:
16  PublicBlumBlumShub(const Integer &n, const Integer &seed);
17 
18  unsigned int GenerateBit();
19  byte GenerateByte();
20  void GenerateBlock(byte *output, size_t size);
21  void ProcessData(byte *outString, const byte *inString, size_t length);
22 
23  bool IsSelfInverting() const {return true;}
24  bool IsForwardTransformation() const {return true;}
25 
26 protected:
27  ModularArithmetic modn;
28  word maxBits, bitsLeft;
29  Integer current;
30 
31  friend class BlumGoldwasserPublicKey;
32  friend class BlumGoldwasserPrivateKey;
33 };
34 
35 //! BlumBlumShub with factorization of the modulus
37 {
38 public:
39  // Make sure p and q are both primes congruent to 3 mod 4 and at least 512 bits long,
40  // seed is the secret key and should be about as big as p*q
41  BlumBlumShub(const Integer &p, const Integer &q, const Integer &seed);
42 
43  bool IsRandomAccess() const {return true;}
44  void Seek(lword index);
45 
46 protected:
47  const Integer p, q;
48  const Integer x0;
49 };
50 
51 NAMESPACE_END
52 
53 #endif
bool IsSelfInverting() const
returns whether this transformation is self-inverting (e.g. xor with a keystream) ...
Definition: blumshub.h:23
void Seek(lword index)
for random access ciphers, seek to an absolute position
ring of congruence classes modulo n
Definition: modarith.h:19
interface for random number generators
Definition: cryptlib.h:668
bool IsForwardTransformation() const
returns whether this is an encryption object
Definition: blumshub.h:24
multiple precision integer and basic arithmetics
Definition: integer.h:26
interface for the data processing part of stream ciphers
Definition: cryptlib.h:469
bool IsRandomAccess() const
returns whether this cipher supports random access
Definition: blumshub.h:43
BlumBlumShub with factorization of the modulus.
Definition: blumshub.h:36
BlumBlumShub without factorization of the modulus.
Definition: blumshub.h:12