summaryrefslogtreecommitdiff
path: root/lib/af_alg.h
Commit message (Collapse)AuthorAgeFilesLines
* maint: run 'make update-copyright'Simon Josefsson2023-01-011-1/+1
|
* maint: run 'make update-copyright'Paul Eggert2022-01-011-1/+1
|
* Put LGPLv2+ notices in source files where appropriate.Bruno Haible2021-06-041-8/+8
| | | | | * lib/**.{h,c,gperf}: Use LGPLv2+ notice whenever the module description says so.
* maint: run 'make update-copyright'Paul Eggert2020-12-311-1/+1
|
* maint: Run 'make update-copyright'Paul Eggert2019-12-311-1/+1
|
* Fix typos found by codespell.Tim Rühsen2019-01-121-1/+1
| | | | | * lib/*.[hc]: Fix typos in comments. * pygnulib/*.py: Fix typos in error messages and comments.
* maint: Run 'make update-copyright'Paul Eggert2019-01-011-1/+1
|
* af_alg: recover better from crypto failuresPaul Eggert2018-05-091-6/+9
| | | | | | | | | | * lib/af_alg.c (afalg_stream): Recover from crypto failures if the input stream is seekable, by repositioning the stream back to where it was, possibly by just calling sendfile with an offset arg. This lets us return -EAFNOSUPPORT instead of -EIO in some cases, which lets our callers try again with user-mode code. * modules/crypto/af_alg (Depends-on): Depend on fseeko and ftello instead of on fflush and lseek.
* af_alg: Add ability to use Linux kernel crypto API on data in memory.Bruno Haible2018-05-061-2/+35
| | | | | * lib/af_alg.h (afalg_buffer): New declaration. * lib/af_alg.c (afalg_buffer): New function.
* af_alg: Avoid warnings.Bruno Haible2018-05-061-1/+1
| | | | | * lib/af_alg.h (afalg_stream): Mark fallback declaration as inline. * m4/af_alg.m4 (gl_AF_ALG): Require AC_C_INLINE.
* af_alg: Fix bug with streams that are not at position 0.Bruno Haible2018-05-061-0/+5
| | | | | | | | | | | | * lib/af_alg.c (afalg_stream): Before sendfile, invoke fflush. Don't assume that the stream is positioned at position 0. * lib/af_alg.h (afalg_stream): Mention restriction regarding the state of the stream. * lib/md5.h (md5_stream): Likewise. * lib/sha1.h (sha1_stream): Likewise. * lib/sha256.h (sha256_stream, sha224_stream): Likewise. * lib/sha512.h (sha512_stream, sha384_stream): Likewise. * modules/crypto/af_alg (Depends-on): Add fflush, lseek.
* af_alg: Add configure option to enable/disable use of Linux crypto API.Bruno Haible2018-05-061-1/+1
| | | | | | | | | Suggested by Assaf Gordon <assafgordon@gmail.com>. * m4/af_alg.m4 (gl_AF_ALG): Add AC_ARG_WITH invocation. Define C macro USE_LINUX_CRYPTO_API. * lib/af_alg.h: Test USE_LINUX_CRYPTO_API, not HAVE_LINUX_IF_ALG_H. * lib/af_alg.c: Likewise.
* af_alg: Improve comments.Paul Eggert2018-05-051-12/+9
| | | | * lib/af_alg.h: Use imperatives and tighten up wording.
* af_alg: New module.Bruno Haible2018-05-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib/af_alg.h: Test HAVE_* macro through '#if', not '#ifdef'. * lib/af_alg.c: Include "af_alg.h" before the other header files. * lib/md5.c: Include "af_alg.h" unconditionally. (md5_stream): Invoke afalg_stream unconditionally. * lib/sha1.c: Include "af_alg.h" unconditionally. (sha1_stream): Invoke afalg_stream unconditionally. * lib/sha256.c: Include "af_alg.h" unconditionally. (sha256_stream, sha224_stream): Invoke afalg_stream unconditionally. * lib/sha512.c: Include "af_alg.h" unconditionally. (sha512_stream, sha384_stream): Invoke afalg_stream unconditionally. * m4/af_alg.m4: Renamed from m4/linux-if-alg.m4. (gl_AF_ALG): Renamed from gl_LINUX_IF_ALG_H. * modules/crypto/af_alg: New file. * modules/crypto/md5 (Files): Remove files that are now in the 'crypto/af_alg' module. (Depends-on): Add crypto/af_alg. (configure.ac): Remove gl_LINUX_IF_ALG_H invocation. (Makefile.am): Don't mention af_alg.c here. * modules/crypto/sha1 (Files): Remove files that are now in the 'crypto/af_alg' module. (Depends-on): Add crypto/af_alg. (configure.ac): Remove gl_LINUX_IF_ALG_H invocation. (Makefile.am): Don't mention af_alg.c here. * modules/crypto/sha256 (Files): Remove files that are now in the 'crypto/af_alg' module. (Depends-on): Add crypto/af_alg. (configure.ac): Remove gl_LINUX_IF_ALG_H invocation. (Makefile.am): Don't mention af_alg.c here. * modules/crypto/sha512 (Files): Remove files that are now in the 'crypto/af_alg' module. (Depends-on): Add crypto/af_alg. (configure.ac): Remove gl_LINUX_IF_ALG_H invocation. (Makefile.am): Don't mention af_alg.c here.
* af_alg: Improve function signature.Bruno Haible2018-05-051-2/+2
| | | | | | * lib/af_alg.h (afalg_stream): Swap second and third argument. * lib/af_alg.c (afalg_stream): Likewise. * lib/md5.c, lib/sha1.c, lib/sha256.c, lib/sha512.c: Callers changed.
* af_alg: Add documentation.Bruno Haible2018-05-051-4/+32
| | | | * lib/af_alg.h: Add comments.
* sha1sum: use AF_ALG when availableMatteo Croce2018-05-051-0/+49
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() when possible (regular file with size less or equal than 0x7ffff000 (2,147,479,552) bytes, AKA MAX_RW_COUNT). Use afalg_stream() only in sha1sum for now, but other hashes are possible. The speed gain really depends on the CPU type, on systems which doesn't use libcrypto ranges from ~10% to 320%. This is a test on a Intel(R) Xeon(R) CPU E3-1265L V2 and Debian stretch: $ 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 Signed-off-by: Matteo Croce <mcroce@redhat.com>