summaryrefslogtreecommitdiffstats
path: root/cryptopp562/blumshub.h
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2016-04-13 21:05:14 -0400
committerMalf Furious <m@lfurio.us>2016-04-13 21:05:14 -0400
commit490d36e65ac24e34e3021c2a0947384aee138c88 (patch)
tree418a229fa60708d7796bc61f90794626aefed9d5 /cryptopp562/blumshub.h
downloadcompass-490d36e65ac24e34e3021c2a0947384aee138c88.tar.gz
compass-490d36e65ac24e34e3021c2a0947384aee138c88.zip
Root commit for new Compass repository
This is the Alpha version of ComPASS, originally developed sometime in 2014.
Diffstat (limited to 'cryptopp562/blumshub.h')
-rw-r--r--cryptopp562/blumshub.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/cryptopp562/blumshub.h b/cryptopp562/blumshub.h
new file mode 100644
index 0000000..5e50747
--- /dev/null
+++ b/cryptopp562/blumshub.h
@@ -0,0 +1,53 @@
+#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