+2018-04-28 Matteo Croce <mcroce@redhat.com>
+
+ sha256sum: Use AF_ALG when available.
+ * lib/sha256.c: Include af_alg.h.
+ (sha256_stream, sha224_stream): Use afalg_stream when available.
+ * modules/crypto/sha256 (Files): Add the af_alg files.
+ (configure.ac): Invoke gl_LINUX_IF_ALG_H.
+ (Makefile.am): Add af_alg.c.
+
2018-04-28 Matteo Croce <mcroce@redhat.com>
sha1sum: Use AF_ALG when available.
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_LINUX_IF_ALG_H
+# include "af_alg.h"
+#endif
+
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
#endif
{
struct sha256_ctx ctx;
size_t sum;
+ char *buffer;
+
+#ifdef HAVE_LINUX_IF_ALG_H
+ int ret;
+
+ ret = afalg_stream(stream, resblock, "sha256", SHA256_DIGEST_SIZE);
+ if (!ret)
+ return 0;
+
+ if (ret == -EIO)
+ return 1;
+#endif
- char *buffer = malloc (BLOCKSIZE + 72);
+ buffer = malloc (BLOCKSIZE + 72);
if (!buffer)
return 1;
{
struct sha256_ctx ctx;
size_t sum;
+ char *buffer;
+
+#ifdef HAVE_LINUX_IF_ALG_H
+ int ret;
+
+ ret = afalg_stream(stream, resblock, "sha224", SHA224_DIGEST_SIZE);
+ if (!ret)
+ return 0;
+
+ if (ret == -EIO)
+ return 1;
+#endif
- char *buffer = malloc (BLOCKSIZE + 72);
+ buffer = malloc (BLOCKSIZE + 72);
if (!buffer)
return 1;