summaryrefslogtreecommitdiff
path: root/libavutil/md5.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2007-03-13 12:19:20 +0000
committerMichael Niedermayer <michaelni@gmx.at>2007-03-13 12:19:20 +0000
commitef3c7c33282488796736e6150dbf9c18b68fb3ba (patch)
treeed76221898a38c1e372a167c959b21dbae419e8e /libavutil/md5.c
parente1b62250acd27d3de32585e7c16e19f8b128cdff (diff)
borrow finalization algo from sha1 (100byte smaller)
Originally committed as revision 8383 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil/md5.c')
-rw-r--r--libavutil/md5.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/libavutil/md5.c b/libavutil/md5.c
index 1dfd06b3c2..1f100de35a 100644
--- a/libavutil/md5.c
+++ b/libavutil/md5.c
@@ -139,22 +139,14 @@ void av_md5_update(AVMD5 *ctx, const uint8_t *src, const int len){
}
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);
-
- if( 56 < j ){
- body( ctx->ABCD, (uint32_t*) ctx->block );
- memset(ctx->block, 0, 64);
- }
+ int i;
+ uint64_t finalcount= le2me_64(ctx->len<<3);
- for(i=0; i<8; i++)
- ctx->block[56+i] = (ctx->len << 3) >> (i<<3);
+ av_md5_update(ctx, "\200", 1);
+ while((ctx->len & 63)<56)
+ av_md5_update(ctx, "", 1);
- 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]);