diff options
Diffstat (limited to 'cipher/md5.c')
-rw-r--r-- | cipher/md5.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/cipher/md5.c b/cipher/md5.c index 1b6ad482..79b6e871 100644 --- a/cipher/md5.c +++ b/cipher/md5.c @@ -63,6 +63,7 @@ md5_init( void *context ) ctx->D = 0x10325476; ctx->bctx.nblocks = 0; + ctx->bctx.nblocks_high = 0; ctx->bctx.count = 0; ctx->bctx.blocksize = 64; ctx->bctx.bwrite = transform; @@ -215,16 +216,21 @@ static void md5_final( void *context) { MD5_CONTEXT *hd = context; - u32 t, msb, lsb; + u32 t, th, msb, lsb; byte *p; unsigned int burn; _gcry_md_block_write(hd, NULL, 0); /* flush */; t = hd->bctx.nblocks; + if (sizeof t == sizeof hd->bctx.nblocks) + th = hd->bctx.nblocks_high; + else + th = hd->bctx.nblocks >> 32; + /* multiply by 64 to make a byte count */ lsb = t << 6; - msb = t >> 26; + msb = (th << 6) | (t >> 26); /* add the count */ t = lsb; if( (lsb += hd->bctx.count) < t ) |