summaryrefslogtreecommitdiff
path: root/randpool.cpp
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2005-07-12 04:23:32 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2005-07-12 04:23:32 +0000
commitd5ebf62bed594d1fe6ab616a6bbcbcf0a5892d47 (patch)
tree4b03760892a97a9bc452ebe8b7793bbebd402ad4 /randpool.cpp
parentfa39f51809b4da54a5c2adb3e183b1a625cefb92 (diff)
downloadcryptopp-d5ebf62bed594d1fe6ab616a6bbcbcf0a5892d47.tar.gz
port to MSVC .NET 2005 beta 2
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@198 57ff6487-cd31-0410-9ec3-f628ee90f5f0
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 d28f7a9..c2b44fa 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);