Revert "Forgot the md5.x changes to support md5 on decompression."

This reverts commit 006691ca8e.

md5_midstream no longer needed with decompression using existing buffers too now.
This commit is contained in:
Con Kolivas 2011-02-19 10:35:24 +11:00
parent 7287ab8a66
commit 9e589b3d2e
2 changed files with 13 additions and 24 deletions

34
md5.c
View file

@ -124,15 +124,23 @@ md5_finish_ctx (struct md5_ctx *ctx, void *resbuf)
return md5_read_ctx (ctx, resbuf);
}
int md5_midstream (FILE *stream, struct md5_ctx *ctx)
/* Compute MD5 message digest for bytes read from STREAM. The
resulting message digest number will be written into the 16 bytes
beginning at RESBLOCK. */
int
md5_stream (FILE *stream, void *resblock)
{
struct md5_ctx ctx;
size_t sum;
char *buffer = malloc (BLOCKSIZE + 72);
if (!buffer)
return 1;
/* Iterate over the file contents so far written. */
/* Initialize the computation context. */
md5_init_ctx (&ctx);
/* Iterate over full file contents. */
while (1)
{
/* We read the file in blocks of BLOCKSIZE bytes. One call of the
@ -174,34 +182,18 @@ int md5_midstream (FILE *stream, struct md5_ctx *ctx)
/* Process buffer with BLOCKSIZE bytes. Note that
BLOCKSIZE % 64 == 0
*/
md5_process_block (buffer, BLOCKSIZE, ctx);
md5_process_block (buffer, BLOCKSIZE, &ctx);
}
process_partial_block:
/* Process any remaining bytes. */
if (sum > 0)
md5_process_bytes (buffer, sum, ctx);
free (buffer);
return 0;
}
/* Compute MD5 message digest for bytes read from STREAM. The
resulting message digest number will be written into the 16 bytes
beginning at RESBLOCK. */
int
md5_stream (FILE *stream, void *resblock)
{
struct md5_ctx ctx;
/* Initialize the computation context. */
md5_init_ctx (&ctx);
md5_midstream(stream, &ctx);
md5_process_bytes (buffer, sum, &ctx);
/* Construct result in desired memory. */
md5_finish_ctx (&ctx, resblock);
free (buffer);
return 0;
}

3
md5.h
View file

@ -54,7 +54,6 @@
# define __md5_process_bytes md5_process_bytes
# define __md5_read_ctx md5_read_ctx
# define __md5_stream md5_stream
# define __md5_midstream md5_midstream
#endif
# ifdef __cplusplus
@ -115,8 +114,6 @@ extern void *__md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) __THROW;
beginning at RESBLOCK. */
extern int __md5_stream (FILE *stream, void *resblock) __THROW;
extern int __md5_midstream (FILE *stream, struct md5_ctx *ctx) __THROW;
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
result is always in little endian byte order, so that a byte-wise
output yields to the wanted ASCII representation of the message