summaryrefslogtreecommitdiff
path: root/randpool.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2017-08-02 19:43:56 -0400
committerJeffrey Walton <noloader@gmail.com>2017-08-02 19:43:56 -0400
commit76ff3fc03b64fc2f491fae2e918733c1a153d444 (patch)
tree2aec1d661d783154be4c2ca63ae3b3fa809de652 /randpool.cpp
parent4da4ece5a573196edcc76785e3a2fa0ed8d4b47e (diff)
downloadcryptopp-git-76ff3fc03b64fc2f491fae2e918733c1a153d444.tar.gz
Remove pre-Crypto++ 5.5 interface
Users of OldRandomPool must use the new interface. All that means is they must call IncorporateEntropy instead of Put, and GenerateBlock instead of Get
Diffstat (limited to 'randpool.cpp')
-rw-r--r--randpool.cpp53
1 files changed, 18 insertions, 35 deletions
diff --git a/randpool.cpp b/randpool.cpp
index 1813da54..974760b7 100644
--- a/randpool.cpp
+++ b/randpool.cpp
@@ -88,7 +88,21 @@ OldRandomPool::OldRandomPool(unsigned int poolSize)
void OldRandomPool::IncorporateEntropy(const byte *input, size_t length)
{
- OldRandomPool::Put(input, length);
+ size_t t;
+ while (length > (t = pool.size() - addPos))
+ {
+ xorbuf(pool+addPos, input, t);
+ input += t;
+ length -= t;
+ Stir();
+ }
+
+ if (length)
+ {
+ xorbuf(pool+addPos, input, length);
+ addPos += length;
+ getPos = pool.size(); // Force stir on get
+ }
}
void OldRandomPool::Stir()
@@ -106,36 +120,8 @@ void OldRandomPool::Stir()
getPos = key.size();
}
-size_t OldRandomPool::Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
-{
- CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking);
-
- size_t t;
- while (length > (t = pool.size() - addPos))
- {
- xorbuf(pool+addPos, inString, t);
- inString += t;
- length -= t;
- Stir();
- }
-
- if (length)
- {
- xorbuf(pool+addPos, inString, length);
- addPos += length;
- getPos = pool.size(); // Force stir on get
- }
-
- return 0;
-}
-
-size_t OldRandomPool::TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel, bool blocking)
+void OldRandomPool::GenerateIntoBufferedTransformation(BufferedTransformation &target, const std::string &channel, lword size)
{
- if (!blocking)
- throw NotImplemented("OldRandomPool: nonblocking transfer is not implemented by this object");
-
- lword size = transferBytes;
-
while (size > 0)
{
if (getPos == pool.size())
@@ -144,10 +130,7 @@ size_t OldRandomPool::TransferTo2(BufferedTransformation &target, lword &transfe
target.ChannelPut(channel, pool+getPos, t);
size -= t;
getPos += t;
- }
-
- return 0;
-}
+ }}
byte OldRandomPool::GenerateByte()
{
@@ -160,7 +143,7 @@ byte OldRandomPool::GenerateByte()
void OldRandomPool::GenerateBlock(byte *outString, size_t size)
{
ArraySink sink(outString, size);
- TransferTo(sink, size);
+ GenerateIntoBufferedTransformation(sink, DEFAULT_CHANNEL, size);
}
NAMESPACE_END