[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: md5 cleanup
From: |
Stepan Kasal |
Subject: |
Re: md5 cleanup |
Date: |
Mon, 24 Oct 2005 10:34:13 +0200 |
User-agent: |
Mutt/1.4.1i |
Hello,
On Sun, Oct 23, 2005 at 10:34:18PM -0700, Paul Eggert wrote:
> uint32_t *p = (uint32_t *) ((char *) ctx->buffer + bytes + pad);
> p[0] = SWAP (ctx->total[0] << 3);
> p[1] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
wouldn't the following be more readable?
uint32_t bytes = ctx->buflen;
size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4;
/* Now count remaining bytes. */
ctx->total[0] += bytes;
if (ctx->total[0] < bytes)
++ctx->total[1];
/* Put the 64-bit file length in *bits* at the end of the buffer. */
ctx->buffer[size - 2] = SWAP (ctx->total[0] << 3);
ctx->buffer[size - 1] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
memcpy (&((char*)ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
/* Process last bytes. */
md5_process_block (ctx->buffer, size * 4, ctx);
Do I understand correctly that this is only executed for the last block,
so that it's not necessary to be so careful about each tick?
Have a nice day,
Stepan