Add GenerateKeystream to HC256

This keeps HC-128 and HC-256 consistent
This commit is contained in:
Jeffrey Walton 2023-09-28 09:05:16 -04:00
parent 0bf8798835
commit c6a16ea573
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
2 changed files with 11 additions and 4 deletions

View File

@ -88,6 +88,14 @@ inline word32 HC256Policy::Generate() /*one step of the cipher*/
return (output);
}
void HC256Policy::GenerateKeystream(word32 keystream[4])
{
keystream[0] = Generate();
keystream[1] = Generate();
keystream[2] = Generate();
keystream[3] = Generate();
}
void HC256Policy::CipherSetKey(const NameValuePairs &params, const byte *userKey, size_t keylen)
{
CRYPTOPP_UNUSED(params); CRYPTOPP_UNUSED(keylen);
@ -108,10 +116,7 @@ void HC256Policy::OperateKeystream(KeystreamOperation operation, byte *output, c
while (iterationCount--)
{
FixedSizeSecBlock<word32, 4> keystream;
keystream[0] = Generate();
keystream[1] = Generate();
keystream[2] = Generate();
keystream[3] = Generate();
GenerateKeystream(keystream);
CRYPTOPP_KEYSTREAM_OUTPUT_SWITCH(HC256_OUTPUT, BYTES_PER_ITERATION);
}

View File

@ -39,6 +39,8 @@ protected:
word32 H1(word32 u);
word32 H2(word32 u);
void GenerateKeystream(word32* keystream);
word32 Generate();
private: