* Update context to reflect the concatenation of another buffer full * of bytes. */
| 84 | * of bytes. |
| 85 | */ |
| 86 | void MD5Update(struct MD5Context *ctx, unsigned char *buf, unsigned int len) |
| 87 | { |
| 88 | uint32 t; |
| 89 | |
| 90 | /* Update bitcount */ |
| 91 | |
| 92 | t = ctx->bits[0]; |
| 93 | if ((ctx->bits[0] = t + ((uint32)len << 3)) < t) |
| 94 | ctx->bits[1]++; /* Carry from low to high */ |
| 95 | ctx->bits[1] += len >> 29; |
| 96 | |
| 97 | t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ |
| 98 | |
| 99 | /* Handle any leading odd-sized chunks */ |
| 100 | |
| 101 | if (t) { |
| 102 | unsigned char *p = (unsigned char *)ctx->in + t; |
| 103 | |
| 104 | t = 64 - t; |
| 105 | if (len < t) { |
| 106 | memcpy(p, buf, len); |
| 107 | return; |
| 108 | } |
| 109 | memcpy(p, buf, t); |
| 110 | byteReverse(ctx->in, 16); |
| 111 | MD5Transform(ctx->buf, (uint32 *)ctx->in); |
| 112 | buf += t; |
| 113 | len -= t; |
| 114 | } |
| 115 | /* Process data in 64-byte chunks */ |
| 116 | |
| 117 | while (len >= 64) { |
| 118 | memcpy(ctx->in, buf, 64); |
| 119 | byteReverse(ctx->in, 16); |
| 120 | MD5Transform(ctx->buf, (uint32 *)ctx->in); |
| 121 | buf += 64; |
| 122 | len -= 64; |
| 123 | } |
| 124 | |
| 125 | /* Handle any remaining bytes of data. */ |
| 126 | |
| 127 | memcpy(ctx->in, buf, len); |
| 128 | } |
| 129 | |
| 130 | /* |
| 131 | * Final wrapup - pad to 64-byte boundary with the bit pattern |
no test coverage detected