* 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.
+2018-05-05 Bruno Haible <bruno@clisp.org>
+
+ af_alg: New module.
+ * 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.
+
2018-05-05 Paul Eggert <eggert@cs.ucla.edu>
crypto tests: pacify GCC
#include <config.h>
-#ifdef HAVE_LINUX_IF_ALG_H
+#if HAVE_LINUX_IF_ALG_H
+
+#include "af_alg.h"
#include <unistd.h>
#include <string.h>
#include <sys/sendfile.h>
#include <sys/socket.h>
-#include "af_alg.h"
-
#include "sys-limits.h"
#define BLOCKSIZE 32768
extern "C" {
# endif
-# ifdef HAVE_LINUX_IF_ALG_H
+# if HAVE_LINUX_IF_ALG_H
/* Computes a message digest of the contents of a file.
STREAM is an open file stream. Regular files are handled more efficiently
#include <string.h>
#include <sys/types.h>
-#ifdef HAVE_LINUX_IF_ALG_H
-# include "af_alg.h"
-#endif
+#include "af_alg.h"
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
size_t sum;
char *buffer;
-#ifdef HAVE_LINUX_IF_ALG_H
- int ret;
-
- ret = afalg_stream (stream, "md5", resblock, MD5_DIGEST_SIZE);
- if (!ret)
+ {
+ int ret = afalg_stream (stream, "md5", resblock, MD5_DIGEST_SIZE);
+ if (!ret)
return 0;
- if (ret == -EIO)
+ if (ret == -EIO)
return 1;
-#endif
+ }
buffer = malloc (BLOCKSIZE + 72);
if (!buffer)
#include <stdlib.h>
#include <string.h>
-#ifdef HAVE_LINUX_IF_ALG_H
-# include "af_alg.h"
-#endif
+#include "af_alg.h"
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
#endif
/* Compute SHA1 message digest for bytes read from STREAM. The
- resulting message digest number will be written into the 16 bytes
+ resulting message digest number will be written into the 20 bytes
beginning at RESBLOCK. */
int
sha1_stream (FILE *stream, void *resblock)
struct sha1_ctx ctx;
size_t sum;
char *buffer;
-#ifdef HAVE_LINUX_IF_ALG_H
- int ret;
- ret = afalg_stream (stream, "sha1", resblock, SHA1_DIGEST_SIZE);
- if (!ret)
+ {
+ int ret = afalg_stream (stream, "sha1", resblock, SHA1_DIGEST_SIZE);
+ if (!ret)
return 0;
- if (ret == -EIO)
+ if (ret == -EIO)
return 1;
-#endif
+ }
buffer = malloc (BLOCKSIZE + 72);
if (!buffer)
#include <stdlib.h>
#include <string.h>
-#ifdef HAVE_LINUX_IF_ALG_H
-# include "af_alg.h"
-#endif
+#include "af_alg.h"
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
size_t sum;
char *buffer;
-#ifdef HAVE_LINUX_IF_ALG_H
- int ret;
-
- ret = afalg_stream(stream, "sha256", resblock, SHA256_DIGEST_SIZE);
- if (!ret)
+ {
+ int ret = afalg_stream (stream, "sha256", resblock, SHA256_DIGEST_SIZE);
+ if (!ret)
return 0;
- if (ret == -EIO)
+ if (ret == -EIO)
return 1;
-#endif
+ }
buffer = malloc (BLOCKSIZE + 72);
if (!buffer)
size_t sum;
char *buffer;
-#ifdef HAVE_LINUX_IF_ALG_H
- int ret;
-
- ret = afalg_stream (stream, "sha224", resblock, SHA224_DIGEST_SIZE);
- if (!ret)
+ {
+ int ret = afalg_stream(stream, "sha224", resblock, SHA224_DIGEST_SIZE);
+ if (!ret)
return 0;
- if (ret == -EIO)
+ if (ret == -EIO)
return 1;
-#endif
+ }
buffer = malloc (BLOCKSIZE + 72);
if (!buffer)
#include <stdlib.h>
#include <string.h>
-#ifdef HAVE_LINUX_IF_ALG_H
-# include "af_alg.h"
-#endif
+#include "af_alg.h"
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
size_t sum;
char *buffer;
-#ifdef HAVE_LINUX_IF_ALG_H
- int ret;
-
- ret = afalg_stream (stream, "sha512", resblock, SHA512_DIGEST_SIZE);
- if (!ret)
+ {
+ int ret = afalg_stream (stream, "sha512", resblock, SHA512_DIGEST_SIZE);
+ if (!ret)
return 0;
- if (ret == -EIO)
+ if (ret == -EIO)
return 1;
-#endif
+ }
buffer = malloc (BLOCKSIZE + 72);
if (!buffer)
size_t sum;
char *buffer;
-#ifdef HAVE_LINUX_IF_ALG_H
- int ret;
-
- ret = afalg_stream (stream, "sha384", resblock, SHA384_DIGEST_SIZE);
- if (!ret)
+ {
+ int ret = afalg_stream(stream, "sha384", resblock, SHA384_DIGEST_SIZE);
+ if (!ret)
return 0;
- if (ret == -EIO)
+ if (ret == -EIO)
return 1;
-#endif
+ }
buffer = malloc (BLOCKSIZE + 72);
if (!buffer)
--- /dev/null
+# af_alg.m4 serial 1
+dnl Check whether linux/if_alg.h has needed features.
+
+dnl Copyright 2018 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Matteo Croce.
+
+AC_DEFUN_ONCE([gl_AF_ALG],
+[
+ AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+ AC_CACHE_CHECK([whether linux/if_alg.h has struct sockaddr_alg.],
+ [gl_cv_header_linux_if_alg_salg],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[#include <sys/socket.h>
+ #include <linux/if_alg.h>
+ struct sockaddr_alg salg = {
+ .salg_family = AF_ALG,
+ .salg_type = "hash",
+ .salg_name = "sha1",
+ };]])],
+ [gl_cv_header_linux_if_alg_salg=yes],
+ [gl_cv_header_linux_if_alg_salg=no])])
+ if test "$gl_cv_header_linux_if_alg_salg" = yes; then
+ AC_DEFINE([HAVE_LINUX_IF_ALG_H], [1],
+ [Define to 1 if you have 'struct sockaddr_alg' defined.])
+ fi
+])
+++ /dev/null
-dnl Check whether linux/if_alg.h has needed features.
-
-dnl Copyright 2018 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl From Matteo Croce.
-
-AC_DEFUN_ONCE([gl_LINUX_IF_ALG_H],
-[
- AC_REQUIRE([gl_HEADER_SYS_SOCKET])
- AC_CACHE_CHECK([whether linux/if_alg.h has struct sockaddr_alg.],
- [gl_cv_header_linux_if_alg_salg],
- [AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM([[#include <sys/socket.h>
- #include <linux/if_alg.h>
- struct sockaddr_alg salg = {
- .salg_family = AF_ALG,
- .salg_type = "hash",
- .salg_name = "sha1",
- };]])],
- [gl_cv_header_linux_if_alg_salg=yes],
- [gl_cv_header_linux_if_alg_salg=no])])
- if test "$gl_cv_header_linux_if_alg_salg" = yes; then
- AC_DEFINE([HAVE_LINUX_IF_ALG_H], [1],
- [Define to 1 if you have `struct sockaddr_alg' defined.])
- fi
-])
--- /dev/null
+Description:
+Compute message digest using kernel-supported cryptography algorithms.
+
+Files:
+lib/af_alg.h
+lib/af_alg.c
+lib/sys-limits.h
+m4/af_alg.m4
+
+Depends-on:
+sys_socket
+sys_stat
+
+configure.ac:
+gl_AF_ALG
+
+Makefile.am:
+lib_SOURCES += af_alg.c
+
+Include:
+"af_alg.h"
+
+License:
+LGPLv2+
+
+Maintainer:
+all
lib/gl_openssl.h
lib/md5.h
lib/md5.c
-lib/af_alg.h
-lib/af_alg.c
-lib/sys-limits.h
m4/gl-openssl.m4
m4/md5.m4
-m4/linux-if-alg.m4
Depends-on:
+crypto/af_alg
extern-inline
stdalign
stdint
configure.ac:
gl_MD5
-gl_LINUX_IF_ALG_H
Makefile.am:
-lib_SOURCES += md5.c af_alg.c
+lib_SOURCES += md5.c
Include:
"md5.h"
lib/gl_openssl.h
lib/sha1.h
lib/sha1.c
-lib/af_alg.h
-lib/af_alg.c
-lib/sys-limits.h
m4/gl-openssl.m4
m4/sha1.m4
-m4/linux-if-alg.m4
Depends-on:
+crypto/af_alg
extern-inline
stdalign
stdint
configure.ac:
gl_SHA1
-gl_LINUX_IF_ALG_H
Makefile.am:
-lib_SOURCES += sha1.c af_alg.c
+lib_SOURCES += sha1.c
Include:
"sha1.h"
lib/gl_openssl.h
lib/sha256.h
lib/sha256.c
-lib/af_alg.h
-lib/af_alg.c
-lib/sys-limits.h
m4/gl-openssl.m4
m4/sha256.m4
-m4/linux-if-alg.m4
Depends-on:
+crypto/af_alg
extern-inline
stdalign
stdint
configure.ac:
gl_SHA256
-gl_LINUX_IF_ALG_H
Makefile.am:
-lib_SOURCES += sha256.c af_alg.c
+lib_SOURCES += sha256.c
Include:
"sha256.h"
lib/gl_openssl.h
lib/sha512.h
lib/sha512.c
-lib/af_alg.h
-lib/af_alg.c
-lib/sys-limits.h
m4/gl-openssl.m4
m4/sha512.m4
-m4/linux-if-alg.m4
Depends-on:
+crypto/af_alg
extern-inline
stdalign
stdint
configure.ac:
gl_SHA512
-gl_LINUX_IF_ALG_H
Makefile.am:
-lib_SOURCES += sha512.c af_alg.c
+lib_SOURCES += sha512.c
Include:
"sha512.h"