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

Function ah_input_cb

freebsd/netipsec/xform_ah.c:684–828  ·  view source on GitHub ↗

* AH input callback from the crypto driver. */

Source from the content-addressed store, hash-verified

682 * AH input callback from the crypto driver.
683 */
684static int
685ah_input_cb(struct cryptop *crp)
686{
687 IPSEC_DEBUG_DECLARE(char buf[IPSEC_ADDRSTRLEN]);
688 unsigned char calc[AH_ALEN_MAX];
689 struct mbuf *m;
690 struct xform_data *xd;
691 struct secasvar *sav;
692 struct secasindex *saidx;
693 caddr_t ptr;
694 crypto_session_t cryptoid;
695 int authsize, rplen, ahsize, error, skip, protoff;
696 uint8_t nxt;
697
698 m = crp->crp_buf.cb_mbuf;
699 xd = crp->crp_opaque;
700 CURVNET_SET(xd->vnet);
701 sav = xd->sav;
702 skip = xd->skip;
703 nxt = xd->nxt;
704 protoff = xd->protoff;
705 cryptoid = xd->cryptoid;
706 saidx = &sav->sah->saidx;
707 IPSEC_ASSERT(saidx->dst.sa.sa_family == AF_INET ||
708 saidx->dst.sa.sa_family == AF_INET6,
709 ("unexpected protocol family %u", saidx->dst.sa.sa_family));
710
711 /* Check for crypto errors. */
712 if (crp->crp_etype) {
713 if (crp->crp_etype == EAGAIN) {
714 /* Reset the session ID */
715 if (ipsec_updateid(sav, &crp->crp_session, &cryptoid) != 0)
716 crypto_freesession(cryptoid);
717 xd->cryptoid = crp->crp_session;
718 CURVNET_RESTORE();
719 return (crypto_dispatch(crp));
720 }
721 AHSTAT_INC(ahs_noxform);
722 DPRINTF(("%s: crypto error %d\n", __func__, crp->crp_etype));
723 error = crp->crp_etype;
724 goto bad;
725 } else {
726 AHSTAT_INC(ahs_hist[sav->alg_auth]);
727 crypto_freereq(crp); /* No longer needed. */
728 crp = NULL;
729 }
730
731 /* Shouldn't happen... */
732 if (m == NULL) {
733 AHSTAT_INC(ahs_crypto);
734 DPRINTF(("%s: bogus returned buffer from crypto\n", __func__));
735 error = EINVAL;
736 goto bad;
737 }
738
739 /* Figure out header size. */
740 rplen = HDRSIZE(sav);
741 authsize = AUTHSIZE(sav);

Callers

nothing calls this directly

Calls 15

ipsec_updateidFunction · 0.85
crypto_freesessionFunction · 0.85
crypto_dispatchFunction · 0.85
crypto_freereqFunction · 0.85
ah_hdrsizFunction · 0.85
m_copydataFunction · 0.85
timingsafe_bcmpFunction · 0.85
ipsec_addressFunction · 0.85
m_copybackFunction · 0.85
ipsec_updatereplayFunction · 0.85
m_striphdrFunction · 0.85
ipsec6_common_input_cbFunction · 0.85

Tested by

no test coverage detected