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

2018-04-23 Thread Tim Rühsen
On 23.04.2018 18:52, Matteo Croce wrote: > On Mon, Apr 23, 2018 at 5:07 PM, Tim Rühsen wrote: >> On 04/23/2018 01:17 PM, Matteo Croce wrote: >>> +#include >>> + >>> +#include "af_alg.h" >>> + >>> +/* from linux/include/linux/fs.h: (INT_MAX & PAGE_MASK) */ >>> +#define MAX_RW_COUNT 0x7000 >>>

Re: [PATCH 0/4] Use AF_ALG in checksum utilities

2018-04-23 Thread Bruno Haible
Hi Matteo, > > * says that on x86 > > platforms the same functions can be done through CPU instructions. Are > > these > > instructions privileged? If not, then what are - for this frequent case > > of > > Intel CPUs - the advantag

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

2018-04-23 Thread Matteo Croce
On Mon, Apr 23, 2018 at 5:07 PM, Tim Rühsen wrote: > > On 04/23/2018 01:17 PM, Matteo Croce wrote: >> +#include >> + >> +#include "af_alg.h" >> + >> +/* from linux/include/linux/fs.h: (INT_MAX & PAGE_MASK) */ >> +#define MAX_RW_COUNT 0x7000 >> +#define BLOCKSIZE 32768 >> + >> +int >> +afalg_s

Re: [PATCH 0/4] Use AF_ALG in checksum utilities

2018-04-23 Thread Matteo Croce
On Mon, Apr 23, 2018 at 3:54 PM, Bruno Haible wrote: > Hi Matteo, > >> > Marvell Armada 8040 - MACCHIATOBin Dual shot: >> > >> > $ dd if=/dev/zero bs=1G count=10 |time -p sha1sum >> > a0b6e2ca4e28360a929943e8eb966f703a69dc44 2g.bin >> > >> > real 0m49.390s >> > user 0m46.852s >>

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

2018-04-23 Thread Tim Rühsen
On 04/23/2018 01:17 PM, Matteo Croce wrote: > +#include > + > +#include "af_alg.h" > + > +/* from linux/include/linux/fs.h: (INT_MAX & PAGE_MASK) */ > +#define MAX_RW_COUNT 0x7000 > +#define BLOCKSIZE 32768 > + > +int > +afalg_stream (FILE * stream, void *resblock, const char *alg, int hashle

Re: [PATCH 0/4] Use AF_ALG in checksum utilities

2018-04-23 Thread Bruno Haible
Hi Matteo, > > Marvell Armada 8040 - MACCHIATOBin Dual shot: > > > > $ dd if=/dev/zero bs=1G count=10 |time -p sha1sum > > a0b6e2ca4e28360a929943e8eb966f703a69dc44 2g.bin > > > > real 0m49.390s > > user 0m46.852s > > sys 0m2.076s > > $ dd if=/dev/zero bs=1G count=10 |ti

Re: [PATCH 0/4] Use AF_ALG in checksum utilities

2018-04-23 Thread Matteo Croce
On Mon, Apr 23, 2018 at 3:42 PM, Tim Rühsen wrote: > On 04/23/2018 02:55 PM, Matteo Croce wrote: >> I understand that this won't compile on systems other than Linux, I >> will make a v2 which uses proper macros to avoid build failures on non >> Linux systems, if this patchset is found to be useful

Re: [PATCH 0/4] Use AF_ALG in checksum utilities

2018-04-23 Thread Tim Rühsen
On 04/23/2018 02:55 PM, Matteo Croce wrote: > I understand that this won't compile on systems other than Linux, I > will make a v2 which uses proper macros to avoid build failures on non > Linux systems, if this patchset is found to be useful. > Created PR #4 on the GitHub mirror for review and com

Re: [PATCH 0/4] Use AF_ALG in checksum utilities

2018-04-23 Thread Matteo Croce
On Mon, Apr 23, 2018 at 1:17 PM, Matteo Croce wrote: > 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 > 752ef2

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

2018-04-23 Thread Matteo Croce
Linux supports accessing kernel cryptographic 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 sendf

[PATCH 0/4] Use AF_ALG in checksum utilities

2018-04-23 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

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

2018-04-23 Thread Matteo Croce
Use AF_ALG for sha384 and sha512 too Signed-off-by: Matteo Croce --- lib/sha512.c | 26 -- modules/crypto/sha512 | 5 - 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lib/sha512.c b/lib/sha512.c index 8a6dd4e83..1ba3342bb 100644 --- a/lib/sh

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

2018-04-23 Thread Matteo Croce
Use AF_ALG for sha224 and sha256 too Signed-off-by: Matteo Croce --- lib/sha256.c | 26 -- modules/crypto/sha256 | 5 - 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lib/sha256.c b/lib/sha256.c index 85405b20f..566c24a43 100644 --- a/lib/sh

[PATCH 4/4] md5sum: use kernel crypto API

2018-04-23 Thread Matteo Croce
Use AF_ALG for md5 too Signed-off-by: Matteo Croce --- lib/md5.c | 14 +- modules/crypto/md5 | 5 - 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/md5.c b/lib/md5.c index 68d00a6c7..8a70ddba1 100644 --- a/lib/md5.c +++ b/lib/md5.c @@ -36,6 +36,8 @@