diff options
Diffstat (limited to 'lib/md5.c')
| -rw-r--r-- | lib/md5.c | 15 |
1 files changed, 12 insertions, 3 deletions
| @@ -134,21 +134,29 @@ md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) | |||
| 134 | } | 134 | } |
| 135 | #endif | 135 | #endif |
| 136 | 136 | ||
| 137 | #if defined _LIBC || defined GL_COMPILE_CRYPTO_STREAM | ||
| 138 | |||
| 139 | #include "af_alg.h" | ||
| 140 | |||
| 137 | /* Compute MD5 message digest for bytes read from STREAM. The | 141 | /* Compute MD5 message digest for bytes read from STREAM. The |
| 138 | resulting message digest number will be written into the 16 bytes | 142 | resulting message digest number will be written into the 16 bytes |
| 139 | beginning at RESBLOCK. */ | 143 | beginning at RESBLOCK. */ |
| 140 | int | 144 | int |
| 141 | md5_stream (FILE *stream, void *resblock) | 145 | md5_stream (FILE *stream, void *resblock) |
| 142 | { | 146 | { |
| 143 | struct md5_ctx ctx; | 147 | switch (afalg_stream (stream, "md5", resblock, MD5_DIGEST_SIZE)) |
| 144 | size_t sum; | 148 | { |
| 149 | case 0: return 0; | ||
| 150 | case -EIO: return 1; | ||
| 151 | } | ||
| 145 | 152 | ||
| 146 | char *buffer = malloc (BLOCKSIZE + 72); | 153 | char *buffer = malloc (BLOCKSIZE + 72); |
| 147 | if (!buffer) | 154 | if (!buffer) |
| 148 | return 1; | 155 | return 1; |
| 149 | 156 | ||
| 150 | /* Initialize the computation context. */ | 157 | struct md5_ctx ctx; |
| 151 | md5_init_ctx (&ctx); | 158 | md5_init_ctx (&ctx); |
| 159 | size_t sum; | ||
| 152 | 160 | ||
| 153 | /* Iterate over full file contents. */ | 161 | /* Iterate over full file contents. */ |
| 154 | while (1) | 162 | while (1) |
| @@ -206,6 +214,7 @@ process_partial_block: | |||
| 206 | free (buffer); | 214 | free (buffer); |
| 207 | return 0; | 215 | return 0; |
| 208 | } | 216 | } |
| 217 | #endif | ||
| 209 | 218 | ||
| 210 | #if ! HAVE_OPENSSL_MD5 | 219 | #if ! HAVE_OPENSSL_MD5 |
| 211 | /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The | 220 | /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The |