2019-11-12 10:23:59

by David Sterba

[permalink] [raw]
Subject: [PATCH v2 0/7] BLAKE2b cleanups

Hi,

the patchset implements cleanups suggested by Eric in
https://lore.kernel.org/linux-crypto/[email protected]/

The diff is almost the same, split into pieces with some additional
comments where it would help understand the simplifications. This is
based on v7 of the BLAKE2b patchset.

The self-tests have been run for each patch on x86_64.

V2:
- rename digest_setkey to blake2b_setkey, this is in patch 7 that also
does a rename, to avoid a too-trivial separate patch
- minor withespace fix in patch 6

David Sterba (7):
crypto: blake2b: merge _final implementation to callback
crypto: blake2b: merge blake2 init to api callback
crypto: blake2b: simplify key init
crypto: blake2b: delete unused structs or members
crypto: blake2b: open code set last block helper
crypto: blake2b: merge _update to api callback
crypto: blake2b: rename tfm context and _setkey callback

crypto/blake2b_generic.c | 279 ++++++++++++---------------------------
1 file changed, 82 insertions(+), 197 deletions(-)

--
2.23.0


2019-11-12 10:24:21

by David Sterba

[permalink] [raw]
Subject: [PATCH v2 4/7] crypto: blake2b: delete unused structs or members

All the code for param block has been inlined, last_node and outlen from
the state are not used or have become redundant due to other code.
Remove it.

Signed-off-by: David Sterba <[email protected]>
---
crypto/blake2b_generic.c | 30 ------------------------------
1 file changed, 30 deletions(-)

diff --git a/crypto/blake2b_generic.c b/crypto/blake2b_generic.c
index fd0fbb076058..442c639c9ad9 100644
--- a/crypto/blake2b_generic.c
+++ b/crypto/blake2b_generic.c
@@ -32,10 +32,7 @@

enum blake2b_constant {
BLAKE2B_BLOCKBYTES = 128,
- BLAKE2B_OUTBYTES = 64,
BLAKE2B_KEYBYTES = 64,
- BLAKE2B_SALTBYTES = 16,
- BLAKE2B_PERSONALBYTES = 16
};

struct blake2b_state {
@@ -44,25 +41,8 @@ struct blake2b_state {
u64 f[2];
u8 buf[BLAKE2B_BLOCKBYTES];
size_t buflen;
- size_t outlen;
- u8 last_node;
};

-struct blake2b_param {
- u8 digest_length; /* 1 */
- u8 key_length; /* 2 */
- u8 fanout; /* 3 */
- u8 depth; /* 4 */
- __le32 leaf_length; /* 8 */
- __le32 node_offset; /* 12 */
- __le32 xof_length; /* 16 */
- u8 node_depth; /* 17 */
- u8 inner_length; /* 18 */
- u8 reserved[14]; /* 32 */
- u8 salt[BLAKE2B_SALTBYTES]; /* 48 */
- u8 personal[BLAKE2B_PERSONALBYTES]; /* 64 */
-} __packed;
-
static const u64 blake2b_IV[8] = {
0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL,
0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL,
@@ -85,16 +65,8 @@ 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_lastnode(struct blake2b_state *S)
-{
- S->f[1] = (u64)-1;
-}
-
static void blake2b_set_lastblock(struct blake2b_state *S)
{
- if (S->last_node)
- blake2b_set_lastnode(S);
-
S->f[0] = (u64)-1;
}

@@ -334,8 +306,6 @@ static struct shash_alg blake2b_algs[] = {

static int __init blake2b_mod_init(void)
{
- BUILD_BUG_ON(sizeof(struct blake2b_param) != BLAKE2B_OUTBYTES);
-
return crypto_register_shashes(blake2b_algs, ARRAY_SIZE(blake2b_algs));
}

--
2.23.0

2019-11-13 20:52:16

by Eric Biggers

[permalink] [raw]
Subject: Re: [PATCH v2 0/7] BLAKE2b cleanups

On Tue, Nov 12, 2019 at 11:20:23AM +0100, David Sterba wrote:
> Hi,
>
> the patchset implements cleanups suggested by Eric in
> https://lore.kernel.org/linux-crypto/[email protected]/
>
> The diff is almost the same, split into pieces with some additional
> comments where it would help understand the simplifications. This is
> based on v7 of the BLAKE2b patchset.
>
> The self-tests have been run for each patch on x86_64.
>
> V2:
> - rename digest_setkey to blake2b_setkey, this is in patch 7 that also
> does a rename, to avoid a too-trivial separate patch
> - minor withespace fix in patch 6
>
> David Sterba (7):
> crypto: blake2b: merge _final implementation to callback
> crypto: blake2b: merge blake2 init to api callback
> crypto: blake2b: simplify key init
> crypto: blake2b: delete unused structs or members
> crypto: blake2b: open code set last block helper
> crypto: blake2b: merge _update to api callback
> crypto: blake2b: rename tfm context and _setkey callback
>
> crypto/blake2b_generic.c | 279 ++++++++++++---------------------------
> 1 file changed, 82 insertions(+), 197 deletions(-)

For the series:

Reviewed-by: Eric Biggers <[email protected]>

2019-11-22 11:12:08

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH v2 0/7] BLAKE2b cleanups

David Sterba <[email protected]> wrote:
> Hi,
>
> the patchset implements cleanups suggested by Eric in
> https://lore.kernel.org/linux-crypto/[email protected]/
>
> The diff is almost the same, split into pieces with some additional
> comments where it would help understand the simplifications. This is
> based on v7 of the BLAKE2b patchset.
>
> The self-tests have been run for each patch on x86_64.
>
> V2:
> - rename digest_setkey to blake2b_setkey, this is in patch 7 that also
> does a rename, to avoid a too-trivial separate patch
> - minor withespace fix in patch 6
>
> David Sterba (7):
> crypto: blake2b: merge _final implementation to callback
> crypto: blake2b: merge blake2 init to api callback
> crypto: blake2b: simplify key init
> crypto: blake2b: delete unused structs or members
> crypto: blake2b: open code set last block helper
> crypto: blake2b: merge _update to api callback
> crypto: blake2b: rename tfm context and _setkey callback
>
> crypto/blake2b_generic.c | 279 ++++++++++++---------------------------
> 1 file changed, 82 insertions(+), 197 deletions(-)

All applied. Thanks.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt