MCPcopy Create free account
hub / github.com/crossuo/crossuo / append

Method append

src/Crypt/md5.cpp:236–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

234}
235
236void MD5Crypt::append(md5_state *pms, const unsigned char *data, int nbytes)
237{
238 const unsigned char *p = data;
239 unsigned int nbits = (unsigned int)(nbytes << 3);
240 int left = nbytes, offset = (pms->count[0] >> 3) & 63;
241
242 if (nbytes <= 0)
243 {
244 return;
245 }
246
247 // Update the message length
248 pms->count[1] += nbytes >> 29;
249 pms->count[0] += nbits;
250 if (pms->count[0] < nbits)
251 {
252 pms->count[1]++;
253 }
254
255 // Process an initial partial block
256 if (offset != 0)
257 {
258 int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
259 memcpy(pms->buf + offset, p, copy);
260
261 if (offset + copy < 64)
262 {
263 return;
264 }
265
266 p += copy;
267 left -= copy;
268 process(pms, pms->buf);
269 }
270
271 // Process full blocks
272 for (; left >= 64; p += 64, left -= 64)
273 {
274 process(pms, p);
275 }
276
277 // Process a final partial block
278 if (left != 0)
279 {
280 if (left > 63)
281 {
282 left = 63;
283 }
284 memcpy(pms->buf, p, left);
285 }
286}
287
288void MD5Crypt::finish(md5_state *pms, unsigned char digest[16])
289{

Callers 3

recv_data_stringFunction · 0.45
SendConsoleTextFunction · 0.45
save_controllerFunction · 0.45

Calls 1

memcpyFunction · 0.85

Tested by

no test coverage detected