Latch previous ROUNDS in Salsa and ChaCha ciphers (GH #800)
parent
161d680434
commit
57e869e28b
|
|
@ -345,7 +345,7 @@ void ChaCha_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key,
|
||||||
CRYPTOPP_ASSERT(key); CRYPTOPP_ASSERT(length == 16 || length == 32);
|
CRYPTOPP_ASSERT(key); CRYPTOPP_ASSERT(length == 16 || length == 32);
|
||||||
CRYPTOPP_UNUSED(key); CRYPTOPP_UNUSED(length);
|
CRYPTOPP_UNUSED(key); CRYPTOPP_UNUSED(length);
|
||||||
|
|
||||||
m_rounds = params.GetIntValueWithDefault(Name::Rounds(), 20);
|
m_rounds = params.GetIntValueWithDefault(Name::Rounds(), m_rounds);
|
||||||
if (m_rounds != 20 && m_rounds != 12 && m_rounds != 8)
|
if (m_rounds != 20 && m_rounds != 12 && m_rounds != 8)
|
||||||
throw InvalidRounds(ChaCha::StaticAlgorithmName(), m_rounds);
|
throw InvalidRounds(ChaCha::StaticAlgorithmName(), m_rounds);
|
||||||
|
|
||||||
|
|
|
||||||
2
chacha.h
2
chacha.h
|
|
@ -58,7 +58,7 @@ class CRYPTOPP_NO_VTABLE ChaCha_Policy : public AdditiveCipherConcretePolicy<wor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~ChaCha_Policy() {}
|
virtual ~ChaCha_Policy() {}
|
||||||
ChaCha_Policy() : m_rounds(0) {}
|
ChaCha_Policy() : m_rounds(20) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length);
|
void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length);
|
||||||
|
|
|
||||||
|
|
@ -112,8 +112,7 @@ std::string Salsa20_Policy::AlgorithmProvider() const
|
||||||
|
|
||||||
void Salsa20_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length)
|
void Salsa20_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length)
|
||||||
{
|
{
|
||||||
m_rounds = params.GetIntValueWithDefault(Name::Rounds(), 20);
|
m_rounds = params.GetIntValueWithDefault(Name::Rounds(), m_rounds);
|
||||||
|
|
||||||
if (!(m_rounds == 8 || m_rounds == 12 || m_rounds == 20))
|
if (!(m_rounds == 8 || m_rounds == 12 || m_rounds == 20))
|
||||||
throw InvalidRounds(Salsa20::StaticAlgorithmName(), m_rounds);
|
throw InvalidRounds(Salsa20::StaticAlgorithmName(), m_rounds);
|
||||||
|
|
||||||
|
|
@ -692,8 +691,7 @@ Salsa20_OperateKeystream ENDP
|
||||||
|
|
||||||
void XSalsa20_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length)
|
void XSalsa20_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length)
|
||||||
{
|
{
|
||||||
m_rounds = params.GetIntValueWithDefault(Name::Rounds(), 20);
|
m_rounds = params.GetIntValueWithDefault(Name::Rounds(), m_rounds);
|
||||||
|
|
||||||
if (!(m_rounds == 8 || m_rounds == 12 || m_rounds == 20))
|
if (!(m_rounds == 8 || m_rounds == 12 || m_rounds == 20))
|
||||||
throw InvalidRounds(XSalsa20::StaticAlgorithmName(), m_rounds);
|
throw InvalidRounds(XSalsa20::StaticAlgorithmName(), m_rounds);
|
||||||
|
|
||||||
|
|
|
||||||
1
salsa.h
1
salsa.h
|
|
@ -36,6 +36,7 @@ struct Salsa20_Info : public VariableKeyLength<32, 16, 32, 16, SimpleKeyingInter
|
||||||
class CRYPTOPP_NO_VTABLE Salsa20_Policy : public AdditiveCipherConcretePolicy<word32, 16>
|
class CRYPTOPP_NO_VTABLE Salsa20_Policy : public AdditiveCipherConcretePolicy<word32, 16>
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
Salsa20_Policy() : m_rounds(20) {}
|
||||||
void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length);
|
void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length);
|
||||||
void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
|
void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
|
||||||
void CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length);
|
void CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue