mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
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:
parent
7287ab8a66
commit
9e589b3d2e
34
md5.c
34
md5.c
|
|
@ -124,15 +124,23 @@ md5_finish_ctx (struct md5_ctx *ctx, void *resbuf)
|
||||||
return md5_read_ctx (ctx, 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;
|
size_t sum;
|
||||||
|
|
||||||
char *buffer = malloc (BLOCKSIZE + 72);
|
char *buffer = malloc (BLOCKSIZE + 72);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return 1;
|
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)
|
while (1)
|
||||||
{
|
{
|
||||||
/* We read the file in blocks of BLOCKSIZE bytes. One call of the
|
/* 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
|
/* Process buffer with BLOCKSIZE bytes. Note that
|
||||||
BLOCKSIZE % 64 == 0
|
BLOCKSIZE % 64 == 0
|
||||||
*/
|
*/
|
||||||
md5_process_block (buffer, BLOCKSIZE, ctx);
|
md5_process_block (buffer, BLOCKSIZE, &ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
process_partial_block:
|
process_partial_block:
|
||||||
|
|
||||||
/* Process any remaining bytes. */
|
/* Process any remaining bytes. */
|
||||||
if (sum > 0)
|
if (sum > 0)
|
||||||
md5_process_bytes (buffer, sum, ctx);
|
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);
|
|
||||||
|
|
||||||
/* Construct result in desired memory. */
|
/* Construct result in desired memory. */
|
||||||
md5_finish_ctx (&ctx, resblock);
|
md5_finish_ctx (&ctx, resblock);
|
||||||
|
free (buffer);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
3
md5.h
3
md5.h
|
|
@ -54,7 +54,6 @@
|
||||||
# define __md5_process_bytes md5_process_bytes
|
# define __md5_process_bytes md5_process_bytes
|
||||||
# define __md5_read_ctx md5_read_ctx
|
# define __md5_read_ctx md5_read_ctx
|
||||||
# define __md5_stream md5_stream
|
# define __md5_stream md5_stream
|
||||||
# define __md5_midstream md5_midstream
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# ifdef __cplusplus
|
# ifdef __cplusplus
|
||||||
|
|
@ -115,8 +114,6 @@ extern void *__md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) __THROW;
|
||||||
beginning at RESBLOCK. */
|
beginning at RESBLOCK. */
|
||||||
extern int __md5_stream (FILE *stream, void *resblock) __THROW;
|
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
|
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
|
||||||
result is always in little endian byte order, so that a byte-wise
|
result is always in little endian byte order, so that a byte-wise
|
||||||
output yields to the wanted ASCII representation of the message
|
output yields to the wanted ASCII representation of the message
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue