[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 4/4] md5sum: use kernel crypto API
From: |
Matteo Croce |
Subject: |
[PATCH v2 4/4] md5sum: use kernel crypto API |
Date: |
Wed, 25 Apr 2018 13:28:04 +0200 |
Use AF_ALG for md5 too
Signed-off-by: Matteo Croce <address@hidden>
---
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
- Re: [PATCH v2 1/4] sha1sum: use AF_ALG when available, (continued)
[PATCH v2 2/4] sha256sum: use kernel crypto API, Matteo Croce, 2018/04/25
[PATCH v2 3/4] sha512sum: use kernel crypto API, Matteo Croce, 2018/04/25
[PATCH v2 4/4] md5sum: use kernel crypto API,
Matteo Croce <=