MCPcopy Create free account
hub / github.com/F-Stack/f-stack / crypto_cursor_advance

Function crypto_cursor_advance

freebsd/opencrypto/criov.c:274–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

272SDT_PROBE_DEFINE2(opencrypto, criov, cursor_advance, vmpage, "struct crypto_buffer_cursor*", "size_t");
273
274void
275crypto_cursor_advance(struct crypto_buffer_cursor *cc, size_t amount)
276{
277 size_t remain;
278
279 switch (cc->cc_type) {
280 case CRYPTO_BUF_CONTIG:
281 MPASS(cc->cc_buf_len >= amount);
282 cc->cc_buf += amount;
283 cc->cc_buf_len -= amount;
284 break;
285 case CRYPTO_BUF_MBUF:
286 for (;;) {
287 remain = cc->cc_mbuf->m_len - cc->cc_offset;
288 if (amount < remain) {
289 cc->cc_offset += amount;
290 break;
291 }
292 amount -= remain;
293 cc->cc_mbuf = cc->cc_mbuf->m_next;
294 cc->cc_offset = 0;
295 if (amount == 0)
296 break;
297 }
298 break;
299 case CRYPTO_BUF_VMPAGE:
300 for (;;) {
301 SDT_PROBE2(opencrypto, criov, cursor_advance, vmpage,
302 cc, amount);
303 remain = MIN(PAGE_SIZE - cc->cc_offset, cc->cc_buf_len);
304 if (amount < remain) {
305 cc->cc_buf_len -= amount;
306 cc->cc_offset += amount;
307 break;
308 }
309 cc->cc_buf_len -= remain;
310 amount -= remain;
311 cc->cc_vmpage++;
312 cc->cc_offset = 0;
313 if (amount == 0 || cc->cc_buf_len == 0)
314 break;
315 }
316 break;
317 case CRYPTO_BUF_UIO:
318 for (;;) {
319 remain = cc->cc_iov->iov_len - cc->cc_offset;
320 if (amount < remain) {
321 cc->cc_offset += amount;
322 break;
323 }
324 amount -= remain;
325 cc->cc_iov++;
326 cc->cc_offset = 0;
327 if (amount == 0)
328 break;
329 }
330 break;
331 default:

Callers 4

swcr_encdecFunction · 0.85
swcr_gmacFunction · 0.85
swcr_gcmFunction · 0.85
swcr_ccmFunction · 0.85

Calls 1

panicFunction · 0.50

Tested by

no test coverage detected