lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 03 Mar 2024 13:37:10 +0700
From: James Bottomley <James.Bottomley@...senPartnership.com>
To: Lukas Wunner <lukas@...ner.de>, Stefan Berger <stefanb@...ux.ibm.com>
Cc: keyrings@...r.kernel.org, linux-crypto@...r.kernel.org, 
 herbert@...dor.apana.org.au, davem@...emloft.net,
 linux-kernel@...r.kernel.org,  saulo.alessandre@....jus.br
Subject: Re: [PATCH v4 01/12] crypto: ecdsa - Convert byte arrays with key
 coordinates to digits

On Sat, 2024-03-02 at 22:34 +0100, Lukas Wunner wrote:
> On Thu, Feb 29, 2024 at 09:19:56PM -0500, Stefan Berger wrote:
[...]
> > @@ -238,12 +237,17 @@ static int ecdsa_set_pub_key(struct
> > crypto_akcipher *tfm, const void *key, unsig
> >                 return -EINVAL;
> >  
> >         keylen--;
> > -       ndigits = (keylen >> 1) / sizeof(u64);
> > +       digitlen = keylen >> 1;
> > +
> > +       ndigits = DIV_ROUND_UP(digitlen, sizeof(u64));
> 
> Instead of introducing an additional digitlen variable, you could
> just use keylen.  It seems it's not used in the remainder of the
> function, so modifying it is harmless:
> 
>         keylen--;
> +       keylen >>= 1;
> -       ndigits = (keylen >> 1) / sizeof(u64);
> +       ndigits = DIV_ROUND_UP(digitlen, sizeof(u64));
> 
> Just a suggestion.

The compiler will optimize the variables like this anyway (reuse
registers or frames after a current consumer becomes unused) so there's
no requirement to do this for efficiency, the only real question is
whether using digitlen is clearer than reusing keylen, which I'll leave
to the author.

James


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ