* Update context to reflect the concatenation of another buffer full * of bytes. */
| 43 | * of bytes. |
| 44 | */ |
| 45 | void md5_update(md5_ctx *ctx, const void *_buf, unsigned len) |
| 46 | { |
| 47 | const uint8_t *buf = (const uint8_t *) _buf; |
| 48 | uint32_t t; |
| 49 | |
| 50 | /* Update byte count */ |
| 51 | |
| 52 | t = ctx->bytes[0]; |
| 53 | if ((ctx->bytes[0] = t + len) < t) |
| 54 | ctx->bytes[1]++; /* Carry from low to high */ |
| 55 | |
| 56 | t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */ |
| 57 | if (t > len) { |
| 58 | memcpy((uint8_t *) ctx->in + 64 - t, buf, len); |
| 59 | return; |
| 60 | } |
| 61 | /* First chunk is an odd size */ |
| 62 | memcpy((uint8_t *) ctx->in + 64 - t, buf, t); |
| 63 | byteSwap(ctx->in, 16); |
| 64 | md5_transform(ctx->buf, ctx->in); |
| 65 | buf += t; |
| 66 | len -= t; |
| 67 | |
| 68 | /* Process data in 64-byte chunks */ |
| 69 | while (len >= 64) { |
| 70 | memcpy(ctx->in, buf, 64); |
| 71 | byteSwap(ctx->in, 16); |
| 72 | md5_transform(ctx->buf, ctx->in); |
| 73 | buf += 64; |
| 74 | len -= 64; |
| 75 | } |
| 76 | |
| 77 | /* Handle any remaining bytes of data. */ |
| 78 | memcpy(ctx->in, buf, len); |
| 79 | } |
| 80 | |
| 81 | /* |
| 82 | * Final wrapup - pad to 64-byte boundary with the bit pattern |
no test coverage detected
searching dependent graphs…