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: fix malfunction of socket functions on HP-UX in 64-bit mode

2018-04-25 Thread Tom G. Christensen
On 24/04/18 20:08, Bruno Haible wrote: Tom G. Christensen wrote: This testcase uses SO_REUSEPORT which is not available everywhere. From Solaris 9: test-getsockname.c: In function 'open_server_socket': test-getsockname.c:43:30: error: 'SO_REUSEPORT' undeclared (first use in this function)

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 4/4] md5sum: use kernel crypto API

2018-04-25 Thread Matteo Croce
Use AF_ALG for md5 too Signed-off-by: Matteo Croce --- lib/md5.c | 20 +++- modules/crypto/md5 | 4 +++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/md5.c b/lib/md5.c index 68d00a6c7..8e60a549f 100644 --- a/lib/md5.c +++ b/lib/md5.c @@ -32,6 +32,

[PATCH v2 3/4] sha512sum: use kernel crypto API

2018-04-25 Thread Matteo Croce
Use AF_ALG for sha384 and sha512 too Signed-off-by: Matteo Croce --- lib/sha512.c | 34 -- modules/crypto/sha512 | 4 +++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/lib/sha512.c b/lib/sha512.c index 8a6dd4e83..1d3471f20 100644 --- a

[PATCH v2 2/4] sha256sum: use kernel crypto API

2018-04-25 Thread Matteo Croce
Use AF_ALG for sha224 and sha256 too Signed-off-by: Matteo Croce --- lib/sha256.c | 34 -- modules/crypto/sha256 | 4 +++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/lib/sha256.c b/lib/sha256.c index 85405b20f..7924040cd 100644 --- a

[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

[PATCH v2 0/4] Use AF_ALG in checksum utilities

2018-04-25 Thread Matteo Croce
Let md5sum and all sha*sum utilities use Linux kernel cryptographic API via the AF_ALG address family. Speed gain depends on the CPU type: Xeon E3-1265L V2: $ truncate -s 2GB 2g.bin $ time sha1sum 2g.bin 752ef2367f479e79e4f0cded9c270c2890506ab0 2g.bin real0m4.829s user