Use AF_ALG for sha384 and sha512 too Signed-off-by: Matteo Croce <mcr...@redhat.com> --- lib/sha512.c | 32 ++++++++++++++++++++++++++++++-- modules/crypto/sha512 | 6 +++++- 2 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/lib/sha512.c b/lib/sha512.c index 8a6dd4e83..72e5fdd24 100644 --- a/lib/sha512.c +++ b/lib/sha512.c @@ -32,6 +32,10 @@ #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 @@ -185,8 +189,20 @@ sha512_stream (FILE *stream, void *resblock) { struct sha512_ctx ctx; size_t sum; + char *buffer; + +#ifdef HAVE_LINUX_IF_ALG_H + int ret; + + ret = afalg_stream(stream, resblock, "sha512", SHA512_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; @@ -256,8 +272,20 @@ sha384_stream (FILE *stream, void *resblock) { struct sha512_ctx ctx; size_t sum; + char *buffer; + +#ifdef HAVE_LINUX_IF_ALG_H + int ret; + + ret = afalg_stream(stream, resblock, "sha384", SHA384_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/sha512 b/modules/crypto/sha512 index 4c97604cd..6d0dd1019 100644 --- a/modules/crypto/sha512 +++ b/modules/crypto/sha512 @@ -5,8 +5,11 @@ Files: lib/gl_openssl.h lib/sha512.h lib/sha512.c +lib/af_alg.h +lib/af_alg.c m4/gl-openssl.m4 m4/sha512.m4 +m4/linux-if-alg.m4 Depends-on: extern-inline @@ -16,9 +19,10 @@ u64 configure.ac: gl_SHA512 +gl_LINUX_IF_ALG_H Makefile.am: -lib_SOURCES += sha512.c +lib_SOURCES += sha512.c af_alg.c Include: "sha512.h" -- 2.14.3