diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-03-23 21:53:08 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-03-23 21:53:08 +0100 |
commit | 561f10539494ce6cba62d58dab2a6686e04c760b (patch) | |
tree | f9d4cb50653ffa7473bdf148b900145aff8e4074 /CryptoPP/blumshub.cpp | |
parent | MemDumpAnalysis now outputs executable to MCServer folder and debugging starts there. (diff) | |
download | cuberite-561f10539494ce6cba62d58dab2a6686e04c760b.tar cuberite-561f10539494ce6cba62d58dab2a6686e04c760b.tar.gz cuberite-561f10539494ce6cba62d58dab2a6686e04c760b.tar.bz2 cuberite-561f10539494ce6cba62d58dab2a6686e04c760b.tar.lz cuberite-561f10539494ce6cba62d58dab2a6686e04c760b.tar.xz cuberite-561f10539494ce6cba62d58dab2a6686e04c760b.tar.zst cuberite-561f10539494ce6cba62d58dab2a6686e04c760b.zip |
Diffstat (limited to 'CryptoPP/blumshub.cpp')
-rw-r--r-- | CryptoPP/blumshub.cpp | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/CryptoPP/blumshub.cpp b/CryptoPP/blumshub.cpp deleted file mode 100644 index be9b75829..000000000 --- a/CryptoPP/blumshub.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// blumshub.cpp - written and placed in the public domain by Wei Dai - -#include "pch.h" -#include "blumshub.h" - -NAMESPACE_BEGIN(CryptoPP) - -PublicBlumBlumShub::PublicBlumBlumShub(const Integer &n, const Integer &seed) - : modn(n), - maxBits(BitPrecision(n.BitCount())-1) -{ - current = modn.Square(modn.Square(seed)); - bitsLeft = maxBits; -} - -unsigned int PublicBlumBlumShub::GenerateBit() -{ - if (bitsLeft==0) - { - current = modn.Square(current); - bitsLeft = maxBits; - } - - return current.GetBit(--bitsLeft); -} - -byte PublicBlumBlumShub::GenerateByte() -{ - byte b=0; - for (int i=0; i<8; i++) - b = (b << 1) | PublicBlumBlumShub::GenerateBit(); - return b; -} - -void PublicBlumBlumShub::GenerateBlock(byte *output, size_t size) -{ - while (size--) - *output++ = PublicBlumBlumShub::GenerateByte(); -} - -void PublicBlumBlumShub::ProcessData(byte *outString, const byte *inString, size_t length) -{ - while (length--) - *outString++ = *inString++ ^ PublicBlumBlumShub::GenerateByte(); -} - -BlumBlumShub::BlumBlumShub(const Integer &p, const Integer &q, const Integer &seed) - : PublicBlumBlumShub(p*q, seed), - p(p), q(q), - x0(modn.Square(seed)) -{ -} - -void BlumBlumShub::Seek(lword index) -{ - Integer i(Integer::POSITIVE, index); - i *= 8; - Integer e = a_exp_b_mod_c (2, i / maxBits + 1, (p-1)*(q-1)); - current = modn.Exponentiate(x0, e); - bitsLeft = maxBits - i % maxBits; -} - -NAMESPACE_END |