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.
pull/157/head^2
DevJPM 2016-04-22 15:49:29 +02:00
parent 275afb4955
commit 040347968b
1 changed files with 4 additions and 2 deletions

View File

@ -29,8 +29,10 @@ void ChaCha_TestInstantiations()
void ChaCha_Policy::CipherSetKey(const NameValuePairs &params, const byte *key, size_t length) void ChaCha_Policy::CipherSetKey(const NameValuePairs &params, const byte *key, size_t length)
{ {
CRYPTOPP_UNUSED(params); m_rounds = params.GetIntValueWithDefault(Name::Rounds(), 20);
assert(length == 16 || length == 32);
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" // "expand 16-byte k" or "expand 32-byte k"
m_state[0] = 0x61707865; m_state[0] = 0x61707865;