summaryrefslogtreecommitdiff
path: root/lib/sha1.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sha1.c')
-rw-r--r--lib/sha1.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/sha1.c b/lib/sha1.c
index ce0f0b2e71f..8306d887da5 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -122,21 +122,29 @@ sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf)
}
#endif
+#ifdef GL_COMPILE_CRYPTO_STREAM
+
+#include "af_alg.h"
+
/* Compute SHA1 message digest for bytes read from STREAM. The
- resulting message digest number will be written into the 16 bytes
+ resulting message digest number will be written into the 20 bytes
beginning at RESBLOCK. */
int
sha1_stream (FILE *stream, void *resblock)
{
- struct sha1_ctx ctx;
- size_t sum;
+ switch (afalg_stream (stream, "sha1", resblock, SHA1_DIGEST_SIZE))
+ {
+ case 0: return 0;
+ case -EIO: return 1;
+ }
char *buffer = malloc (BLOCKSIZE + 72);
if (!buffer)
return 1;
- /* Initialize the computation context. */
+ struct sha1_ctx ctx;
sha1_init_ctx (&ctx);
+ size_t sum;
/* Iterate over full file contents. */
while (1)
@@ -194,6 +202,7 @@ sha1_stream (FILE *stream, void *resblock)
free (buffer);
return 0;
}
+#endif
#if ! HAVE_OPENSSL_SHA1
/* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The