| 155 | #endif |
| 156 | |
| 157 | void md5_update(md_context *ctx, const uchar *input, uint32 length) |
| 158 | { |
| 159 | uint32 left, fill; |
| 160 | |
| 161 | if (!length) |
| 162 | return; |
| 163 | |
| 164 | left = ctx->totalN & 0x3F; |
| 165 | fill = CSUM_CHUNK - left; |
| 166 | |
| 167 | ctx->totalN += length; |
| 168 | ctx->totalN &= 0xFFFFFFFF; |
| 169 | |
| 170 | if (ctx->totalN < length) |
| 171 | ctx->totalN2++; |
| 172 | |
| 173 | if (left && length >= fill) { |
| 174 | memcpy(ctx->buffer + left, input, fill); |
| 175 | md5_process(ctx, ctx->buffer); |
| 176 | length -= fill; |
| 177 | input += fill; |
| 178 | left = 0; |
| 179 | } |
| 180 | |
| 181 | #ifdef USE_MD5_ASM /* { */ |
| 182 | if (length >= CSUM_CHUNK) { |
| 183 | uint32 chunks = length / CSUM_CHUNK; |
| 184 | md5_process_asm(ctx, input, chunks); |
| 185 | length -= chunks * CSUM_CHUNK; |
| 186 | input += chunks * CSUM_CHUNK; |
| 187 | } |
| 188 | #else /* } { */ |
| 189 | while (length >= CSUM_CHUNK) { |
| 190 | md5_process(ctx, input); |
| 191 | length -= CSUM_CHUNK; |
| 192 | input += CSUM_CHUNK; |
| 193 | } |
| 194 | #endif /* } */ |
| 195 | |
| 196 | if (length) |
| 197 | memcpy(ctx->buffer + left, input, length); |
| 198 | } |
| 199 | |
| 200 | static const uchar md5_padding[CSUM_CHUNK] = { 0x80 }; |
| 201 |
no test coverage detected