Revision e1b62250

View differences:

libavutil/md5.c
38 38
    uint8_t  block[64];
39 39
    uint32_t ABCD[4];
40 40
    uint64_t len;
41
    int      b_used;
42 41
} AVMD5;
43 42

  
44 43
const int av_md5_size= sizeof(AVMD5);
......
117 116

  
118 117
void av_md5_init(AVMD5 *ctx){
119 118
    ctx->len    = 0;
120
    ctx->b_used = 0;
121 119

  
122 120
    ctx->ABCD[0] = 0x10325476;
123 121
    ctx->ABCD[1] = 0x98badcfe;
......
126 124
}
127 125

  
128 126
void av_md5_update(AVMD5 *ctx, const uint8_t *src, const int len){
129
    int i;
127
    int i, j;
130 128

  
129
    j= ctx->len & 63;
131 130
    ctx->len += len;
132 131

  
133 132
    for( i = 0; i < len; i++ ){
134
        ctx->block[ ctx->b_used++ ] = src[i];
135
        if( 64 == ctx->b_used ){
133
        ctx->block[j++] = src[i];
134
        if( 64 == j ){
136 135
            body(ctx->ABCD, (uint32_t*) ctx->block);
137
            ctx->b_used = 0;
136
            j = 0;
138 137
        }
139 138
    }
140 139
}
141 140

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

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

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

  
149
    if( 56 < ctx->b_used ){
149
    if( 56 < j ){
150 150
        body( ctx->ABCD, (uint32_t*) ctx->block );
151 151
        memset(ctx->block, 0, 64);
152 152
    }

Also available in: Unified diff