Use AF_ALG for md5 too
Signed-off-by: Matteo Croce <[email protected]>
---
lib/md5.c | 20 +++++++++++++++++++-
modules/crypto/md5 | 4 +++-
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/lib/md5.c b/lib/md5.c
index 68d00a6c7..8e60a549f 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -32,6 +32,12 @@
#include <string.h>
#include <sys/types.h>
+#include <sys/socket.h>
+
+#ifdef AF_ALG
+# include "af_alg.h"
+#endif
+
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
#endif
@@ -142,8 +148,20 @@ md5_stream (FILE *stream, void *resblock)
{
struct md5_ctx ctx;
size_t sum;
+ char *buffer;
+
+#ifdef AF_ALG
+ int ret;
+
+ ret = afalg_stream(stream, resblock, "md5", MD5_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;
diff --git a/modules/crypto/md5 b/modules/crypto/md5
index e5fb39ced..ef9ec9916 100644
--- a/modules/crypto/md5
+++ b/modules/crypto/md5
@@ -5,6 +5,8 @@ Files:
lib/gl_openssl.h
lib/md5.h
lib/md5.c
+lib/af_alg.h
+lib/af_alg.c
m4/gl-openssl.m4
m4/md5.m4
@@ -17,7 +19,7 @@ configure.ac:
gl_MD5
Makefile.am:
-lib_SOURCES += md5.c
+lib_SOURCES += md5.c af_alg.c
Include:
"md5.h"
--
2.14.3