From 040347968b3c9a77ae095a930d46ef8bf7525d25 Mon Sep 17 00:00:00 2001 From: DevJPM Date: Fri, 22 Apr 2016 15:49:29 +0200 Subject: [PATCH] Changed behavior to accept keys from NameValuePair Previously the ChaCha main function didn't actually accept the round count from the params argument. This was in the local repo at the time of commitment but somehow didn't get pushed. This is now fixed. --- chacha.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/chacha.cpp b/chacha.cpp index 5c1c4624..40a00406 100755 --- a/chacha.cpp +++ b/chacha.cpp @@ -29,8 +29,10 @@ void ChaCha_TestInstantiations() void ChaCha_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length) { - CRYPTOPP_UNUSED(params); - assert(length == 16 || length == 32); + m_rounds = params.GetIntValueWithDefault(Name::Rounds(), 20); + + if (!(m_rounds == 8 || m_rounds == 12 || m_rounds == 20)) + throw InvalidRounds(ChaCha::StaticAlgorithmName(), m_rounds); // "expand 16-byte k" or "expand 32-byte k" m_state[0] = 0x61707865;