[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 0/4] Use AF_ALG in checksum utilities
From: |
Matteo Croce |
Subject: |
Re: [PATCH 0/4] Use AF_ALG in checksum utilities |
Date: |
Mon, 23 Apr 2018 14:55:17 +0200 |
On Mon, Apr 23, 2018 at 1:17 PM, Matteo Croce <address@hidden> 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
> 752ef2367f479e79e4f0cded9c270c2890506ab0 2g.bin
>
> real 0m4.829s
> user 0m4.437s
> sys 0m0.391s
> $ time ./sha1sum-afalg 2g.bin
> 752ef2367f479e79e4f0cded9c270c2890506ab0 2g.bin
>
> real 0m3.164s
> user 0m0.000s
> sys 0m3.162s
>
> Xeon E3-1240 v6:
>
> $ time sha1sum disk.qcow2
> 47be301f86c71c20eae4ccc5bab4c02e09e729a4 disk.qcow2
>
> real 0m28.390s
> user 0m13.352s
> sys 0m1.376s
> $ time ./sha1sum-afalg disk.qcow2
> 47be301f86c71c20eae4ccc5bab4c02e09e729a4 disk.qcow2
>
> real 0m8.373s
> user 0m0.052s
> sys 0m8.308s
>
> 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 |time -p ./sha1sum-afalg
> a0b6e2ca4e28360a929943e8eb966f703a69dc44 2g.bin
>
> real 0m15.104s
> user 0m0.052s
> sys 0m15.008s
>
> Correctness of the implementation was tested with the following script:
>
> for alg in md5sum sha1sum sha224sum sha256sum sha384sum sha512sum; do
> for len in 0 1 1234 4000222; do
> hash1=$(dd status=none if=/dev/zero bs=1 count=$len |$alg)
> hash2=$(dd status=none if=/dev/zero bs=1 count=$len |src/$alg)
> [ "$hash1" = "$hash2" ] || exec echo "$alg: hash differs with
> data length $len!"
> done
> done
>
>
> Matteo Croce (4):
> sha1sum: use AF_ALG when available
> sha256sum: use kernel crypto API
> sha512sum: use kernel crypto API
> md5sum: use kernel crypto API
>
> lib/af_alg.c | 102
> ++++++++++++++++++++++++++++++++++++++++++++++++++
> lib/af_alg.h | 46 +++++++++++++++++++++++
> lib/md5.c | 14 ++++++-
> lib/sha1.c | 13 ++++++-
> lib/sha256.c | 26 ++++++++++++-
> lib/sha512.c | 26 ++++++++++++-
> modules/crypto/md5 | 5 ++-
> modules/crypto/sha1 | 5 ++-
> modules/crypto/sha256 | 5 ++-
> modules/crypto/sha512 | 5 ++-
> 10 files changed, 237 insertions(+), 10 deletions(-)
> create mode 100644 lib/af_alg.c
> create mode 100644 lib/af_alg.h
>
> --
> 2.14.3
>
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 comments via GH interface.
--
Matteo Croce
per aspera ad upstream
- [PATCH 0/4] Use AF_ALG in checksum utilities, Matteo Croce, 2018/04/23
- [PATCH 4/4] md5sum: use kernel crypto API, Matteo Croce, 2018/04/23
- Re: [PATCH 0/4] Use AF_ALG in checksum utilities,
Matteo Croce <=
- Re: [PATCH 0/4] Use AF_ALG in checksum utilities, Matteo Croce, 2018/04/24
- Re: [PATCH 0/4] Use AF_ALG in checksum utilities, Bruno Haible, 2018/04/24
- Re: [PATCH 0/4] Use AF_ALG in checksum utilities, Dmitry V. Levin, 2018/04/24