MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / md5_append

Function md5_append

example/cacheCluster/md5.c:322–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320}
321
322void
323md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
324{
325 const md5_byte_t *p = data;
326 int left = nbytes;
327 int offset = (pms->count[0] >> 3) & 63;
328 md5_word_t nbits = (md5_word_t)(nbytes << 3);
329
330 if (nbytes <= 0)
331 return;
332
333 /* Update the message length. */
334 pms->count[1] += nbytes >> 29;
335 pms->count[0] += nbits;
336 if (pms->count[0] < nbits)
337 pms->count[1]++;
338
339 /* Process an initial partial block. */
340 if (offset) {
341 int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
342
343 memcpy(pms->buf + offset, p, copy);
344 if (offset + copy < 64)
345 return;
346 p += copy;
347 left -= copy;
348 md5_process(pms, pms->buf);
349 }
350
351 /* Process full blocks. */
352 for (; left >= 64; p += 64, left -= 64)
353 md5_process(pms, p);
354
355 /* Process a final partial block. */
356 if (left)
357 memcpy(pms->buf, p, left);
358}
359
360void
361md5_finish(md5_state_t *pms, md5_byte_t digest[16])

Callers 3

md5_finishFunction · 0.70
md5_digestFunction · 0.70
ketama_md5_digestFunction · 0.50

Calls 1

md5_processFunction · 0.70

Tested by

no test coverage detected