MCPcopy Create free account
hub / github.com/acl-dev/acl / md5_update

Function md5_update

lib_acl_cpp/samples/md5/md5_c.cpp:45–79  ·  view source on GitHub ↗

* Update context to reflect the concatenation of another buffer full * of bytes. */

Source from the content-addressed store, hash-verified

43 * of bytes.
44 */
45void 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

Callers 2

md5_keyFunction · 0.85
md5_stringFunction · 0.85

Calls 3

memcpyFunction · 0.85
md5_transformFunction · 0.85
byteSwapFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…