fix CTR mode not allowing NULL as IV
parent
d43f0c7321
commit
d938406410
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue