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

Function esp_input_cb

freebsd/netipsec/xform_esp.c:480–668  ·  view source on GitHub ↗

* ESP input callback from the crypto driver. */

Source from the content-addressed store, hash-verified

478 * ESP input callback from the crypto driver.
479 */
480static int
481esp_input_cb(struct cryptop *crp)
482{
483 IPSEC_DEBUG_DECLARE(char buf[128]);
484 uint8_t lastthree[3];
485 const struct auth_hash *esph;
486 struct mbuf *m;
487 struct xform_data *xd;
488 struct secasvar *sav;
489 struct secasindex *saidx;
490 crypto_session_t cryptoid;
491 int hlen, skip, protoff, error, alen;
492
493 m = crp->crp_buf.cb_mbuf;
494 xd = crp->crp_opaque;
495 CURVNET_SET(xd->vnet);
496 sav = xd->sav;
497 skip = xd->skip;
498 protoff = xd->protoff;
499 cryptoid = xd->cryptoid;
500 saidx = &sav->sah->saidx;
501 esph = sav->tdb_authalgxform;
502
503 /* Check for crypto errors */
504 if (crp->crp_etype) {
505 if (crp->crp_etype == EAGAIN) {
506 /* Reset the session ID */
507 if (ipsec_updateid(sav, &crp->crp_session, &cryptoid) != 0)
508 crypto_freesession(cryptoid);
509 xd->cryptoid = crp->crp_session;
510 CURVNET_RESTORE();
511 return (crypto_dispatch(crp));
512 }
513
514 /* EBADMSG indicates authentication failure. */
515 if (!(crp->crp_etype == EBADMSG && esph != NULL)) {
516 ESPSTAT_INC(esps_noxform);
517 DPRINTF(("%s: crypto error %d\n", __func__,
518 crp->crp_etype));
519 error = crp->crp_etype;
520 goto bad;
521 }
522 }
523
524 /* Shouldn't happen... */
525 if (m == NULL) {
526 ESPSTAT_INC(esps_crypto);
527 DPRINTF(("%s: bogus returned buffer from crypto\n", __func__));
528 error = EINVAL;
529 goto bad;
530 }
531 ESPSTAT_INC(esps_hist[sav->alg_enc]);
532
533 /* If authentication was performed, check now. */
534 if (esph != NULL) {
535 alen = xform_ah_authsize(esph);
536 AHSTAT_INC(ahs_hist[sav->alg_auth]);
537 if (crp->crp_etype == EBADMSG) {

Callers

nothing calls this directly

Calls 15

ipsec_updateidFunction · 0.85
crypto_freesessionFunction · 0.85
crypto_dispatchFunction · 0.85
xform_ah_authsizeFunction · 0.85
ipsec_addressFunction · 0.85
m_adjFunction · 0.85
crypto_freereqFunction · 0.85
m_copydataFunction · 0.85
ipsec_updatereplayFunction · 0.85
ipsec_sa2strFunction · 0.85
m_striphdrFunction · 0.85
m_copybackFunction · 0.85

Tested by

no test coverage detected