X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fsec%2Fhash%2Fmd5.c;h=e4d2c135be86e48bb07fd97cb6d59cbfa712fe00;hb=1997bcac9db9a289afa5ca6d4fea4b75aef329d6;hp=7d6812d50cb0a133dfd8f959c13e3dea8737453f;hpb=223e404509d628fa73d99d93964737a7fc9e9695;p=bertos.git diff --git a/bertos/sec/hash/md5.c b/bertos/sec/hash/md5.c index 7d6812d5..e4d2c135 100644 --- a/bertos/sec/hash/md5.c +++ b/bertos/sec/hash/md5.c @@ -67,23 +67,26 @@ static void MD5_update(Hash *h, const void* vbuf, size_t len) /* Handle any leading odd-sized chunks */ - if (t) { + if (t) + { uint8_t *p = (uint8_t*) ctx->in + t; t = 64 - t; - if (len < t) { + if (len < t) + { memcpy(p, buf, len); return; } memcpy(p, buf, t); - byteReverse(aligned_ptr, 16); - MD5Transform(ctx->buf, aligned_ptr); + byteReverse(aligned_ptr, 16); + MD5Transform(ctx->buf, aligned_ptr); buf += t; len -= t; } /* Process data in 64-byte chunks */ - while (len >= 64) { + while (len >= 64) + { memcpy(ctx->in, buf, 64); byteReverse(aligned_ptr, 16); MD5Transform(ctx->buf, aligned_ptr); @@ -122,7 +125,8 @@ static uint8_t* MD5_final(struct Hash *h) count = 64 - 1 - count; /* Pad out to 56 mod 64 */ - if (count < 8) { + if (count < 8) + { /* Two lots of padding: Pad the first block to 64 bytes */ memset(p, 0, count); byteReverse(aligned_ptr, 16); @@ -130,10 +134,13 @@ static uint8_t* MD5_final(struct Hash *h) /* Now fill the next block with 56 bytes */ memset(ctx->in, 0, 56); - } else { + } + else + { /* Pad block to 56 bytes */ memset(p, 0, count - 8); } + byteReverse(aligned_ptr, 14); /* Append length in bits and transform */