summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2010-08-05 09:48:04 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2010-08-05 09:48:04 +0000
commit71b5051ebc9d2558818e272ae92e20abb48fc88c (patch)
tree881a275084027522d12baa3ea9c63105e5c35ccf
parent2b729488b9a3944a384bdaa13fecc34b3ba6de92 (diff)
downloadcryptopp-71b5051ebc9d2558818e272ae92e20abb48fc88c.tar.gz
fix CTR mode not allowing NULL as IV
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@516 57ff6487-cd31-0410-9ec3-f628ee90f5f0
-rw-r--r--cryptlib.cpp2
-rw-r--r--modes.cpp4
2 files changed, 4 insertions, 2 deletions
diff --git a/cryptlib.cpp b/cryptlib.cpp
index dadd9ce..df138dd 100644
--- a/cryptlib.cpp
+++ b/cryptlib.cpp
@@ -87,7 +87,7 @@ void SimpleKeyingInterface::ThrowIfResynchronizable()
void SimpleKeyingInterface::ThrowIfInvalidIV(const byte *iv)
{
- if (!iv && !(IVRequirement() == INTERNALLY_GENERATED_IV || IVRequirement() == UNIQUE_IV || !IsResynchronizable()))
+ if (!iv && IVRequirement() == UNPREDICTABLE_RANDOM_IV)
throw InvalidArgument(GetAlgorithm().AlgorithmName() + ": this object cannot use a null IV");
}
diff --git a/modes.cpp b/modes.cpp
index 789fafb..4633228 100644
--- a/modes.cpp
+++ b/modes.cpp
@@ -56,7 +56,8 @@ void CFB_ModePolicy::TransformRegister()
void CFB_ModePolicy::CipherResynchronize(const byte *iv, size_t length)
{
- memcpy_s(m_register, m_register.size(), iv, BlockSize());
+ assert(length == BlockSize());
+ CopyOrZero(m_register, iv, length);
TransformRegister();
}
@@ -85,6 +86,7 @@ void OFB_ModePolicy::WriteKeystream(byte *keystreamBuffer, size_t iterationCount
void OFB_ModePolicy::CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length)
{
+ assert(length == BlockSize());
CopyOrZero(m_register, iv, length);
}