return v;
}
+static inline void
+le32enc(void *buf, uint32_t v)
+{
+ uint8_t *p = buf;
+
+ p[0] = (v >> 0) & 0xff;
+ p[1] = (v >> 8) & 0xff;
+ p[2] = (v >> 16) & 0xff;
+ p[3] = (v >> 24) & 0xff;
+}
+
static inline void
le64enc(void *buf, uint64_t v)
{
void
md5_final(struct md5 *M, uint8_t h[16])
{
+ unsigned n;
assert(M->i < sizeof(M->block));
assert(M->i == M->b % 64);
md5_compress(M->state, M->block);
/* Reveal the complete state. (Sorry, length-extension!) */
- (void)memcpy(h, M->state, sizeof(M->state));
+ for (n = 0; n < sizeof(M->state)/sizeof(M->state[0]); n++)
+ le32enc(&h[4*n], M->state[n]);
/* Zero it all. */
(void)explicit_memset(M, 0, sizeof M);