[PATCH] crypto/{md5,sha1,sha256,sha512}: simplify

2018-05-05 Thread Paul Eggert
* lib/md5.c (md5_stream): * lib/sha1.c (sha1_stream): * lib/sha256.c (shaxxx_stream): Simplify, partly by assuming C99. * lib/sha256.c (shaxxx_stream): New function, which implements both sha256 and sha224. Simplify, partly by assuming C99. (sha256_stream, sha224_stream): Use it to avoid code dupli

[PATCH] af_alg: Improve comments.

2018-05-05 Thread Paul Eggert
* lib/af_alg.h: Use imperatives and tighten up wording. --- ChangeLog| 5 + lib/af_alg.h | 21 + 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8230d8470..7f1f5b032 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +20

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 v3 0/4] Use AF_ALG in checksum utilities

2018-05-05 Thread Bruno Haible
This patch addresses the code duplication issue in the module descriptions. At the same time, it enables some of the best practices for gnulib modules. In particular, the best practice is not to write #if some_condition #include "af_alg.h" #endif but instead #include "af_alg.h" and make

[PATCH 1/2] af_alg: minor style improvements

2018-05-05 Thread Paul Eggert
* lib/af_alg.c (afalg_stream): Prefer C99 style decl-after-statement, since we’re already assuming C99. Clarify by strengthening the bind test and omit unnecessary assignment. --- ChangeLog| 5 + lib/af_alg.c | 26 +++--- 2 files changed, 16 insertions(+), 15 deletion

[PATCH 2/2] crypto tests: pacify GCC

2018-05-05 Thread Paul Eggert
* tests/test-digest.h (test_digest_on_files): Don’t assume digest size fits in int (!). --- ChangeLog | 4 tests/test-digest.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index bdf18d44f..58fa4a648 100644 --- a/ChangeLog +++ b/ChangeLo

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

2018-05-05 Thread Bruno Haible
The 4 tests that I added all fail on the empty file. Example: $ ./test-sha1 sha1_stream produced wrong result. Expected: \xda\x39\xa3\xee\x5e\x6b\x4b\x0d\x32\x55\xbf\xef\x95\x60\x18\x90\xaf\xd8\x07\x09 Got: \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 S

[PATCH] sys-limits.h: new file for crypto and safe I/O

2018-05-05 Thread Paul Eggert
* lib/af_alg.c: Include sys-limits.h. (MAX_RW_COUNT): Remove. Use replaced by SYS_BUFSIZE_MAX. (afalg_stream): Also reject negative sizes for sendfile; they should not happen and the code is a bit cleaner and faster this way. * lib/safe-read.c: Include sys-limits.h. (BUGGY_READ_MAXIMUM): Remove.

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

2018-05-05 Thread Bruno Haible
While writing the documentation, I noticed that the function has an argument list that is hard to remember: - an input argument (stream), - an output buffer (resblock), - an input argument (alg), - the size of the output buffer. It is better to reorder the arguments so as to: 1. group th

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

2018-05-05 Thread Bruno Haible
Also, I get this compilation warning: af_alg.c: In function ‘afalg_stream’: af_alg.c:72:56: warning: implicit declaration of function ‘S_TYPEISTMO’ [-Wimplicit-function-declaration] && (S_ISREG (st.st_mode) || S_TYPEISSHM (&st) || S_TYPEISTMO (&st))

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

2018-05-05 Thread Bruno Haible
Creating a testdir produces an error: $ ./gnulib-tool --create-testdir --dir=t2 --single-configure --symlink crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 ... configure.ac:197: warning: gl_HEADER_SYS_SOCKET is m4_require'd but not m4_defun'd configure.ac:29: gl_INIT is expanded from... conf

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

2018-05-05 Thread Bruno Haible
Lack of documentation is addressed by this patch. 2018-05-05 Bruno Haible af_alg: Add documentation. * lib/af_alg.h: Add comments. diff --git a/lib/af_alg.h b/lib/af_alg.h index 978e21d..e9580d4 100644 --- a/lib/af_alg.h +++ b/lib/af_alg.h @@ -15,7 +15,16 @@ You should ha

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

2018-05-05 Thread Bruno Haible
Lack of unit tests is addressed through these patches. >From fd8f83c7b100f841f7772e9dd83a0b7e182d3b3b Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 5 May 2018 17:38:39 +0200 Subject: [PATCH 1/4] md5 tests: Add test for md5_stream. * tests/test-digest.h: New file. * tests/test-md5.c: Inc

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

2018-05-05 Thread Bruno Haible
Thanks for the patches. There were no further comments in a week, therefore I pushed them in your name. Still to be addressed: - Lack of documentation. - Code duplication. - Lack of unit tests. - Lack of configure option (suggested by Assaf Gordon in [1]). Bruno [1] https://lists.gnu.org

Re: localename on mingw

2018-05-05 Thread Bruno Haible
Eli Zaretskii wrote: > Those considerations seem less important to me than the functionality > of the code on various platforms. The functionality should make sense > first and foremost, whereas the test suite structure should IMO be > secondary to that. In this case, the testsuite pointed to a p

Re: localename on mingw

2018-05-05 Thread Eli Zaretskii
> From: Bruno Haible > Cc: bug-gnulib@gnu.org > Date: Sat, 05 May 2018 10:27:31 +0200 > > > > The test failures occur because the distinction between what happens > > > in gl_locale_name_thread and gl_locale_name_posix is visible > > > to the test suite. > > > > Can you elaborate about this dist

Re: localename on mingw

2018-05-05 Thread Bruno Haible
Eli Zaretskii wrote: > my conclusion was that > Gnulib does want those internal functions to serve some useful > purpose, perhaps for future extensions or for Gnulib code other that > gl_locale_name Correct. These functions are exposed in localename.h. If someone finds them useful, they can use th