Revision ef3c7c33 libavutil/md5.c

View differences:

libavutil/md5.c
139 139
}
140 140

  
141 141
void av_md5_final(AVMD5 *ctx, uint8_t *dst){
142
    int i, j;
143

  
144
    j= ctx->len & 63;
145
    ctx->block[j++] = 0x80;
146

  
147
    memset(&ctx->block[j], 0, 64 - j);
148

  
149
    if( 56 < j ){
150
        body( ctx->ABCD, (uint32_t*) ctx->block );
151
        memset(ctx->block, 0, 64);
152
    }
142
    int i;
143
    uint64_t finalcount= le2me_64(ctx->len<<3);
153 144

  
154
    for(i=0; i<8; i++)
155
        ctx->block[56+i] = (ctx->len << 3) >> (i<<3);
145
    av_md5_update(ctx, "\200", 1);
146
    while((ctx->len & 63)<56)
147
        av_md5_update(ctx, "", 1);
156 148

  
157
    body(ctx->ABCD, (uint32_t*) ctx->block);
149
    av_md5_update(ctx, &finalcount, 8);
158 150

  
159 151
    for(i=0; i<4; i++)
160 152
        ((uint32_t*)dst)[i]= le2me_32(ctx->ABCD[3-i]);

Also available in: Unified diff