Re: [PATCH v2 1/4] sha1sum: use AF_ALG when available

2018-05-05 Thread Bruno Haible
Assaf Gordon wrote on 2018-04-25: > On more general note, while the Crypto API is available since version 2.6.38, > There are still some issues popping here and there. > for example: > https://security-tracker.debian.org/tracker/CVE-2016-8646 > https://bugzilla.redhat.com/show_bug.cgi?id=139589

Re: [PATCH v2 1/4] sha1sum: use AF_ALG when available

2018-04-27 Thread Paul Eggert
On 04/27/2018 08:50 AM, Matteo Croce wrote: Does this require a change in the coreutils project configure.ac too? I don't see why. Only Gnulib-supplied code needs to worry about HAVE_LINUX_IF_ALG_H, right? So the configury can all be done in the Gnulib-supplied lib/*.m4 file. Although 'config

Re: [PATCH v2 1/4] sha1sum: use AF_ALG when available

2018-04-27 Thread Matteo Croce
On Wed, Apr 25, 2018 at 2:25 PM, Dmitry V. Levin wrote: > As struct sockaddr_alg is not provided by glibc, > you'd have to check for HAVE_LINUX_IF_ALG_H after all. > Does this require a change in the coreutils project configure.ac too? Regards, -- Matteo Croce per aspera ad upstream

Re: [PATCH v2 1/4] sha1sum: use AF_ALG when available

2018-04-26 Thread Paul Eggert
On 04/26/2018 09:02 AM, Matteo Croce wrote: I assume that C99 is safe to use in gnulib, good to know Yes. Until recently we did require C89 in Gnulib because Awk still wanted C89. However, that last holdout has finally given up the ghost so C99isms are OK if they are portable in practice. I n

Re: [PATCH v2 1/4] sha1sum: use AF_ALG when available

2018-04-26 Thread Matteo Croce
On Wed, Apr 25, 2018 at 9:07 PM, Paul Eggert wrote: > Thanks for working on this. Some comments: > Thanks for the review! > On 04/25/2018 04:26 AM, Matteo Croce wrote: >> >> + This file is part of the GNU C Library. > > > Is it really part of glibc? If not, please remove that comment. > Right

Re: [PATCH v2 1/4] sha1sum: use AF_ALG when available

2018-04-25 Thread Matteo Croce
On Wed, Apr 25, 2018 at 7:41 PM, Bernhard Voelker wrote: > On 04/25/2018 01:26 PM, Matteo Croce wrote: >> +#define BLOCKSIZE 32768 > > Did you try different buffer sizes? > > In coreutils, we have a little script to determine the optimal BLOCKSIZE > - which is 128*1024 since 2014: > > https://git.

Re: [PATCH v2 1/4] sha1sum: use AF_ALG when available

2018-04-25 Thread Matteo Croce
On Wed, Apr 25, 2018 at 7:34 PM, Assaf Gordon wrote: > Hello Matteo, > > On Wed, Apr 25, 2018 at 01:26:08PM +0200, Matteo Croce wrote: >> Linux supports accessing kernel crypto API via AF_ALG since >> version 2.6.38. Coreutils uses libcrypto when available and fallbacks to >> generic C implementat

Re: [PATCH v2 1/4] sha1sum: use AF_ALG when available

2018-04-25 Thread Matteo Croce
On Wed, Apr 25, 2018 at 2:25 PM, Dmitry V. Levin wrote: > On Wed, Apr 25, 2018 at 01:26:08PM +0200, Matteo Croce wrote: > [...] >> +#include >> + >> +#include >> + >> +#ifdef AF_ALG >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include "af_alg.h" >> + >> +/

Re: [PATCH v2 1/4] sha1sum: use AF_ALG when available

2018-04-25 Thread Paul Eggert
Thanks for working on this. Some comments: On 04/25/2018 04:26 AM, Matteo Croce wrote: + This file is part of the GNU C Library. Is it really part of glibc? If not, please remove that comment. + if (strlen (alg) >= sizeof(salg.salg_name)) +return -EINVAL; ... + strcpy ((char *) sa

Re: [PATCH v2 1/4] sha1sum: use AF_ALG when available

2018-04-25 Thread Bernhard Voelker
On 04/25/2018 01:26 PM, Matteo Croce wrote: > +#define BLOCKSIZE 32768 Did you try different buffer sizes? In coreutils, we have a little script to determine the optimal BLOCKSIZE - which is 128*1024 since 2014: https://git.sv.gnu.org/cgit/coreutils.git/tree/src/ioblksize.h?id=22424dde74d0 > +

Re: [PATCH v2 1/4] sha1sum: use AF_ALG when available

2018-04-25 Thread Assaf Gordon
Hello Matteo, On Wed, Apr 25, 2018 at 01:26:08PM +0200, Matteo Croce wrote: > Linux supports accessing kernel crypto API via AF_ALG since > version 2.6.38. Coreutils uses libcrypto when available and fallbacks to > generic C implementation of various hashing functions. Not exactly: coreutils (and

Re: [PATCH v2 1/4] sha1sum: use AF_ALG when available

2018-04-25 Thread Dmitry V. Levin
On Wed, Apr 25, 2018 at 01:26:08PM +0200, Matteo Croce wrote: [...] > +#include > + > +#include > + > +#ifdef AF_ALG > + > +#include > +#include > +#include > +#include > +#include > + > +#include "af_alg.h" > + > +/* from linux/include/linux/fs.h: (INT_MAX & PAGE_MASK) */ > +#define MAX_RW_

[PATCH v2 1/4] sha1sum: use AF_ALG when available

2018-04-25 Thread Matteo Croce
Linux supports accessing kernel crypto API via AF_ALG since version 2.6.38. Coreutils uses libcrypto when available and fallbacks to generic C implementation of various hashing functions. Add a generic afalg_stream() function which uses AF_ALG to calculate the hash of a stream and use sendfile() w