diff md5.c @ 313:b4277e786617 libavutil

borrow finalization algo from sha1 (100byte smaller)
author michael
date Tue, 13 Mar 2007 12:19:20 +0000
parents 93d504c22609
children 8b21778cb357
line wrap: on
line diff
--- a/md5.c	Tue Mar 13 11:57:26 2007 +0000
+++ b/md5.c	Tue Mar 13 12:19:20 2007 +0000
@@ -139,22 +139,14 @@
 }
 
 void av_md5_final(AVMD5 *ctx, uint8_t *dst){
-    int i, j;
-
-    j= ctx->len & 63;
-    ctx->block[j++] = 0x80;
-
-    memset(&ctx->block[j], 0, 64 - j);
+    int i;
+    uint64_t finalcount= le2me_64(ctx->len<<3);
 
-    if( 56 < j ){
-        body( ctx->ABCD, (uint32_t*) ctx->block );
-        memset(ctx->block, 0, 64);
-    }
+    av_md5_update(ctx, "\200", 1);
+    while((ctx->len & 63)<56)
+        av_md5_update(ctx, "", 1);
 
-    for(i=0; i<8; i++)
-        ctx->block[56+i] = (ctx->len << 3) >> (i<<3);
-
-    body(ctx->ABCD, (uint32_t*) ctx->block);
+    av_md5_update(ctx, &finalcount, 8);
 
     for(i=0; i<4; i++)
         ((uint32_t*)dst)[i]= le2me_32(ctx->ABCD[3-i]);