Commit 13b956bb authored by Niels Möller's avatar Niels Möller

(md5_digest): Use _nettle_write_le32.

Rev: nettle/md5.c:1.2
parent 9b36817b
......@@ -36,6 +36,7 @@
#include "md5.h"
#include "macros.h"
#include "nettle-write.h"
static void
md5_final(struct md5_ctx *ctx);
......@@ -97,34 +98,11 @@ void
md5_digest(struct md5_ctx *ctx,
unsigned length,
uint8_t *digest)
{
unsigned i;
unsigned words;
unsigned leftover;
{
assert(length <= MD5_DIGEST_SIZE);
md5_final(ctx);
words = length / 4;
leftover = length % 4;
/* Little endian order */
for (i = 0; i < words; i++, digest += 4)
LE_WRITE_UINT32(digest, ctx->digest[i]);
if (leftover)
{
uint32_t word;
unsigned j;
assert(i < _MD5_DIGEST_LENGTH);
/* Still least significant byte first. */
for (word = ctx->digest[i], j = 0; j < leftover;
j++, word >>= 8)
digest[j] = word & 0xff;
}
_nettle_write_le32(length, digest, ctx->digest);
md5_init(ctx);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment