linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: David Sterba <dsterba@suse.com>,
	linux-crypto@vger.kernel.org, ard.biesheuvel@linaro.org
Subject: Re: [PATCH v4 1/5] crypto: add blake2b generic implementation
Date: Sun, 13 Oct 2019 19:44:41 +0200	[thread overview]
Message-ID: <20191013174441.GL2751@twin.jikos.cz> (raw)
In-Reply-To: <20191011180439.GB235973@gmail.com>

On Fri, Oct 11, 2019 at 11:04:40AM -0700, Eric Biggers wrote:
> > +struct blake2b_param
> > +{
> 
> It should be 'struct blake2b_param {'
> 
> checkpatch.pl should warn about this.  Can you fix the checkpatch warnings that
> make sense to fix?

I fixed all the { at the end of line of struct definitions and left all
of type

  ERROR: space prohibited after that open square bracket '['
  #276: FILE: crypto/blake2b_generic.c:200:
  +       v[ 9] = blake2b_IV[1];

and

  WARNING: line over 80 characters
  #304: FILE: crypto/blake2b_generic.c:228:
  +static void blake2b_update(struct blake2b_state *S, const void *pin, size_t inlen)

ie. where the ) or ); is beyond 80 but does not otherwise hurt
readability unlike forced newline and parameters on another line. This
is my prefrence in code I otherwise work on but I'll follow what's
common practice in crypto/.

> > +/* init xors IV with 
> > +static int blake2b_init_param(struct blake2b_state *S,
> > +			      const struct blake2b_param *P)
> > +{
> > +	const u8 *p = (const u8 *)(P);
> > +	size_t i;
> > +
> > +	blake2b_init0(S);
> > +
> > +	/* IV XOR ParamBlock */
> > +	for (i = 0; i < 8; ++i)
> > +		S->h[i] ^= get_unaligned_le64(p + sizeof(S->h[i]) * i);
> > +
> > +	S->outlen = P->digest_length;
> > +	return 0;
> > +}
> 
> No need for this to have a return value anymore.  Same with:
> 
> 	blake2b_init_param()
> 	blake2b_update()
> 	blake2b_init()
> 	blake2b_init_key()
> 	blake2b_final()
> 
> The code would be more readable if they returned void, since otherwise it gives
> the impression that errors can occur.

Make sense.

> > +static int blake2b_update(struct blake2b_state *S, const void *pin, size_t inlen)
> > +{
> > +	const unsigned char *in = (const unsigned char *)pin;
> 
> Convention is to use 'u8', not 'unsigned char'.

Fixed.

> > +MODULE_ALIAS_CRYPTO("blake2b");
> > +MODULE_ALIAS_CRYPTO("blake2b-generic");
> 
> Should remove these module aliases now that the "blake2b" algorithm was removed.

A bit more of typing 'modprobe blake2-512' but I have checked if other
modules use a bare algo name as an alias and found none. So for
consistency I'll remove the 2 lines.

  reply	other threads:[~2019-10-13 17:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11 16:52 [PATCH v4 0/5] BLAKE2b generic implementation David Sterba
2019-10-11 16:52 ` [PATCH v4 1/5] crypto: add blake2b " David Sterba
2019-10-11 18:04   ` Eric Biggers
2019-10-13 17:44     ` David Sterba [this message]
2019-10-11 18:11   ` Eric Biggers
2019-10-11 16:52 ` [PATCH v4 2/5] crypto: add test vectors for blake2b-160 David Sterba
2019-10-11 16:52 ` [PATCH v4 3/5] crypto: add test vectors for blake2b-256 David Sterba
2019-10-11 16:52 ` [PATCH v4 4/5] crypto: add test vectors for blake2b-384 David Sterba
2019-10-11 16:52 ` [PATCH v4 5/5] crypto: add test vectors for blake2b-512 David Sterba
2019-10-11 17:15 ` [PATCH v4 0/5] BLAKE2b generic implementation David Sterba
2019-10-11 17:57 ` Eric Biggers
2019-10-13 19:50   ` David Sterba
2019-10-14  2:54     ` Eric Biggers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191013174441.GL2751@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=ard.biesheuvel@linaro.org \
    --cc=dsterba@suse.com \
    --cc=linux-crypto@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).