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