Crypto++ 8.2
Free C&
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
13NAMESPACE_BEGIN(CryptoPP)
14
15/// BlumBlumShub without factorization of the modulus
18{
19public:
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
32protected:
34 Integer current;
35 word maxBits, bitsLeft;
36};
37
38/// BlumBlumShub with factorization of the modulus
40{
41public:
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
51protected:
52 const Integer p, q;
53 const Integer x0;
54};
55
56NAMESPACE_END
57
58#endif
BlumBlumShub with factorization of the modulus.
Definition: blumshub.h:40
bool IsRandomAccess() const
Determines whether the cipher supports random access.
Definition: blumshub.h:48
void Seek(lword index)
Seek to an absolute position.
Definition: blumshub.cpp:55
Multiple precision integer with arithmetic operations.
Definition: integer.h:50
Ring of congruence classes modulo n.
Definition: modarith.h:39
BlumBlumShub without factorization of the modulus.
Definition: blumshub.h:18
bool IsForwardTransformation() const
Determines if the cipher is being operated in its forward direction.
Definition: blumshub.h:30
bool IsSelfInverting() const
Determines whether the cipher is self-inverting.
Definition: blumshub.h:29
Interface for random number generators.
Definition: cryptlib.h:1384
Interface for the data processing portion of stream ciphers.
Definition: cryptlib.h:918
Abstract base classes that provide a uniform interface to this library.
Multiple precision integer with arithmetic operations.
Class file for performing modular arithmetic.
Crypto++ library namespace.