Crypto++  5.6.5
Free C++ class library of cryptographic schemes
blumshub.h
Go to the documentation of this file.
1 // blumshub.h - originally written and placed in the public domain by Wei Dai
2 
3 //! \file
4 //! \headerfile blumshub.h
5 //! \brief Classes for Blum Blum Shub generator
6 
7 #ifndef CRYPTOPP_BLUMSHUB_H
8 #define CRYPTOPP_BLUMSHUB_H
9 
10 #include "cryptlib.h"
11 #include "modarith.h"
12 #include "integer.h"
13 
14 NAMESPACE_BEGIN(CryptoPP)
15 
16 //! BlumBlumShub without factorization of the modulus
19 {
20 public:
21  virtual ~PublicBlumBlumShub() {}
22 
23  PublicBlumBlumShub(const Integer &n, const Integer &seed);
24 
25  unsigned int GenerateBit();
26  byte GenerateByte();
27  void GenerateBlock(byte *output, size_t size);
28  void ProcessData(byte *outString, const byte *inString, size_t length);
29 
30  bool IsSelfInverting() const {return true;}
31  bool IsForwardTransformation() const {return true;}
32 
33 protected:
34  ModularArithmetic modn;
35  Integer current;
36  word maxBits, bitsLeft;
37 };
38 
39 //! BlumBlumShub with factorization of the modulus
41 {
42 public:
43  virtual ~BlumBlumShub() {}
44 
45  // Make sure p and q are both primes congruent to 3 mod 4 and at least 512 bits long,
46  // seed is the secret key and should be about as big as p*q
47  BlumBlumShub(const Integer &p, const Integer &q, const Integer &seed);
48 
49  bool IsRandomAccess() const {return true;}
50  void Seek(lword index);
51 
52 protected:
53  const Integer p, q;
54  const Integer x0;
55 };
56 
57 NAMESPACE_END
58 
59 #endif
Abstract base classes that provide a uniform interface to this library.
void Seek(lword index)
Seek to an absolute position.
Definition: blumshub.cpp:55
Ring of congruence classes modulo n.
Definition: modarith.h:34
Interface for random number generators.
Definition: cryptlib.h:1190
bool IsSelfInverting() const
Determines whether the cipher is self-inverting.
Definition: blumshub.h:30
bool IsForwardTransformation() const
Determines if the cipher is being operated in its forward direction.
Definition: blumshub.h:31
Multiple precision integer with arithmetic operations.
Definition: integer.h:49
Interface for the data processing portion of stream ciphers.
Definition: cryptlib.h:829
BlumBlumShub with factorization of the modulus.
Definition: blumshub.h:40
Multiple precision integer with arithmetic operations.
Class file for performing modular arithmetic.
Crypto++ library namespace.
BlumBlumShub without factorization of the modulus.
Definition: blumshub.h:17
bool IsRandomAccess() const
Determines whether the cipher supports random access.
Definition: blumshub.h:49