summaryrefslogtreecommitdiff
path: root/randpool.cpp
diff options
context:
space:
mode:
authorweidai <weidai11@users.noreply.github.com>2005-07-12 04:23:32 +0000
committerweidai <weidai11@users.noreply.github.com>2005-07-12 04:23:32 +0000
commit1db8ea50840eb47f0f7d8f3c30d8e0916932ce90 (patch)
tree4b03760892a97a9bc452ebe8b7793bbebd402ad4 /randpool.cpp
parent31068bd68590654dc218bbb183a2ca71bb4af08b (diff)
downloadcryptopp-git-1db8ea50840eb47f0f7d8f3c30d8e0916932ce90.tar.gz
port to MSVC .NET 2005 beta 2
Diffstat (limited to 'randpool.cpp')
-rw-r--r--randpool.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/randpool.cpp b/randpool.cpp
index d28f7a9a..c2b44fac 100644
--- a/randpool.cpp
+++ b/randpool.cpp
@@ -40,9 +40,9 @@ void RandomPool::Stir()
getPos = key.size();
}
-unsigned int RandomPool::Put2(const byte *inString, unsigned int length, int messageEnd, bool blocking)
+size_t RandomPool::Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
{
- unsigned t;
+ size_t t;
while (length > (t = pool.size() - addPos))
{
@@ -62,25 +62,21 @@ unsigned int RandomPool::Put2(const byte *inString, unsigned int length, int mes
return 0;
}
-unsigned int RandomPool::TransferTo2(BufferedTransformation &target, unsigned long &transferBytes, const std::string &channel, bool blocking)
+size_t RandomPool::TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel, bool blocking)
{
if (!blocking)
throw NotImplemented("RandomPool: nonblocking transfer is not implemented by this object");
- unsigned int t;
- unsigned long size = transferBytes;
+ lword size = transferBytes;
- while (size > (t = pool.size() - getPos))
+ while (size > 0)
{
+ if (getPos == pool.size())
+ Stir();
+ size_t t = UnsignedMin(pool.size() - getPos, size);
target.ChannelPut(channel, pool+getPos, t);
size -= t;
- Stir();
- }
-
- if (size)
- {
- target.ChannelPut(channel, pool+getPos, size);
- getPos += size;
+ getPos += t;
}
return 0;
@@ -94,7 +90,7 @@ byte RandomPool::GenerateByte()
return pool[getPos++];
}
-void RandomPool::GenerateBlock(byte *outString, unsigned int size)
+void RandomPool::GenerateBlock(byte *outString, size_t size)
{
ArraySink sink(outString, size);
TransferTo(sink, size);