Skip to content

Commit

Permalink
Add GenerateKeystream to HC256
Browse files Browse the repository at this point in the history
This keeps HC-128 and HC-256 consistent
  • Loading branch information
noloader committed Sep 28, 2023
1 parent 0bf8798 commit c6a16ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 9 additions & 4 deletions hc256.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions hc256.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class HC256Policy : public AdditiveCipherConcretePolicy<word32, 4>, public HC256

word32 H1(word32 u);
word32 H2(word32 u);

void GenerateKeystream(word32* keystream);
word32 Generate();

private:
Expand Down

0 comments on commit c6a16ea

Please sign in to comment.