Skip to content

Commit

Permalink
crypto: blake2b - open code set last block helper
Browse files Browse the repository at this point in the history
The helper is trival and called once, inlining makes things simpler.
There's a comment to tie it back to the idea behind the code.

Signed-off-by: David Sterba <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
kdave authored and herbertx committed Nov 22, 2019
1 parent d063d63 commit a2e4bdc
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions crypto/blake2b_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ static const u8 blake2b_sigma[12][16] = {
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }
};

static void blake2b_set_lastblock(struct blake2b_state *S)
{
S->f[0] = (u64)-1;
}

static void blake2b_increment_counter(struct blake2b_state *S, const u64 inc)
{
S->t[0] += inc;
Expand Down Expand Up @@ -231,7 +226,8 @@ static int blake2b_final(struct shash_desc *desc, u8 *out)
size_t i;

blake2b_increment_counter(state, state->buflen);
blake2b_set_lastblock(state);
/* Set last block */
state->f[0] = (u64)-1;
/* Padding */
memset(state->buf + state->buflen, 0, BLAKE2B_BLOCKBYTES - state->buflen);
blake2b_compress(state, state->buf);
Expand Down

0 comments on commit a2e4bdc

Please sign in to comment.