[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/4] md5sum: use kernel crypto API
From: |
Matteo Croce |
Subject: |
[PATCH 4/4] md5sum: use kernel crypto API |
Date: |
Mon, 23 Apr 2018 13:17:19 +0200 |
Use AF_ALG for md5 too
Signed-off-by: Matteo Croce <address@hidden>
---
lib/md5.c | 14 +++++++++++++-
modules/crypto/md5 | 5 ++++-
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/lib/md5.c b/lib/md5.c
index 68d00a6c7..8a70ddba1 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -36,6 +36,8 @@
# include "unlocked-io.h"
#endif
+#include "af_alg.h"
+
#ifdef _LIBC
# include <endian.h>
# if __BYTE_ORDER == __BIG_ENDIAN
@@ -143,7 +145,17 @@ md5_stream (FILE *stream, void *resblock)
struct md5_ctx ctx;
size_t sum;
- char *buffer = malloc (BLOCKSIZE + 72);
+ int ret;
+ char *buffer;
+
+ ret = afalg_stream(stream, resblock, "md5", MD5_DIGEST_SIZE);
+ if (!ret)
+ return 0;
+
+ if (ret == -EIO)
+ return 1;
+
+ buffer = malloc (BLOCKSIZE + 72);
if (!buffer)
return 1;
diff --git a/modules/crypto/md5 b/modules/crypto/md5
index e5fb39ced..6f22f12f0 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,10 +19,11 @@ configure.ac:
gl_MD5
Makefile.am:
-lib_SOURCES += md5.c
+lib_SOURCES += md5.c af_alg.c
Include:
"md5.h"
+"af_alg.h"
Link:
$(LIB_CRYPTO)
--
2.14.3