Changeset View
Changeset View
Standalone View
Standalone View
sys/netipsec/xform_esp.c
Show First 20 Lines • Show All 383 Lines • ▼ Show 20 Lines | esp_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff) | ||||
/* Crypto operation descriptor */ | /* Crypto operation descriptor */ | ||||
crp->crp_ilen = m->m_pkthdr.len; /* Total input length */ | crp->crp_ilen = m->m_pkthdr.len; /* Total input length */ | ||||
crp->crp_flags = CRYPTO_F_IMBUF | CRYPTO_F_CBIFSYNC; | crp->crp_flags = CRYPTO_F_IMBUF | CRYPTO_F_CBIFSYNC; | ||||
if (V_async_crypto) | if (V_async_crypto) | ||||
crp->crp_flags |= CRYPTO_F_ASYNC | CRYPTO_F_ASYNC_KEEPORDER; | crp->crp_flags |= CRYPTO_F_ASYNC | CRYPTO_F_ASYNC_KEEPORDER; | ||||
crp->crp_buf = (caddr_t) m; | crp->crp_buf = (caddr_t) m; | ||||
crp->crp_callback = esp_input_cb; | crp->crp_callback = esp_input_cb; | ||||
crp->crp_sid = cryptoid; | crp->crp_session = cryptoid; | ||||
crp->crp_opaque = (caddr_t) xd; | crp->crp_opaque = (caddr_t) xd; | ||||
/* These are passed as-is to the callback */ | /* These are passed as-is to the callback */ | ||||
xd->sav = sav; | xd->sav = sav; | ||||
xd->protoff = protoff; | xd->protoff = protoff; | ||||
xd->skip = skip; | xd->skip = skip; | ||||
xd->cryptoid = cryptoid; | xd->cryptoid = cryptoid; | ||||
xd->vnet = curvnet; | xd->vnet = curvnet; | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | esp_input_cb(struct cryptop *crp) | ||||
cryptoid = xd->cryptoid; | cryptoid = xd->cryptoid; | ||||
saidx = &sav->sah->saidx; | saidx = &sav->sah->saidx; | ||||
esph = sav->tdb_authalgxform; | esph = sav->tdb_authalgxform; | ||||
/* Check for crypto errors */ | /* Check for crypto errors */ | ||||
if (crp->crp_etype) { | if (crp->crp_etype) { | ||||
if (crp->crp_etype == EAGAIN) { | if (crp->crp_etype == EAGAIN) { | ||||
/* Reset the session ID */ | /* Reset the session ID */ | ||||
if (ipsec_updateid(sav, &crp->crp_sid, &cryptoid) != 0) | if (ipsec_updateid(sav, &crp->crp_session, &cryptoid) != 0) | ||||
crypto_freesession(cryptoid); | crypto_freesession(cryptoid); | ||||
xd->cryptoid = crp->crp_sid; | xd->cryptoid = crp->crp_session; | ||||
CURVNET_RESTORE(); | CURVNET_RESTORE(); | ||||
return (crypto_dispatch(crp)); | return (crypto_dispatch(crp)); | ||||
} | } | ||||
ESPSTAT_INC(esps_noxform); | ESPSTAT_INC(esps_noxform); | ||||
DPRINTF(("%s: crypto error %d\n", __func__, crp->crp_etype)); | DPRINTF(("%s: crypto error %d\n", __func__, crp->crp_etype)); | ||||
error = crp->crp_etype; | error = crp->crp_etype; | ||||
goto bad; | goto bad; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 366 Lines • ▼ Show 20 Lines | #endif | ||||
/* Crypto operation descriptor. */ | /* Crypto operation descriptor. */ | ||||
crp->crp_ilen = m->m_pkthdr.len; /* Total input length. */ | crp->crp_ilen = m->m_pkthdr.len; /* Total input length. */ | ||||
crp->crp_flags = CRYPTO_F_IMBUF | CRYPTO_F_CBIFSYNC; | crp->crp_flags = CRYPTO_F_IMBUF | CRYPTO_F_CBIFSYNC; | ||||
if (V_async_crypto) | if (V_async_crypto) | ||||
crp->crp_flags |= CRYPTO_F_ASYNC | CRYPTO_F_ASYNC_KEEPORDER; | crp->crp_flags |= CRYPTO_F_ASYNC | CRYPTO_F_ASYNC_KEEPORDER; | ||||
crp->crp_buf = (caddr_t) m; | crp->crp_buf = (caddr_t) m; | ||||
crp->crp_callback = esp_output_cb; | crp->crp_callback = esp_output_cb; | ||||
crp->crp_opaque = (caddr_t) xd; | crp->crp_opaque = (caddr_t) xd; | ||||
crp->crp_sid = cryptoid; | crp->crp_session = cryptoid; | ||||
if (esph) { | if (esph) { | ||||
/* Authentication descriptor. */ | /* Authentication descriptor. */ | ||||
crda->crd_alg = esph->type; | crda->crd_alg = esph->type; | ||||
crda->crd_skip = skip; | crda->crd_skip = skip; | ||||
if (SAV_ISGCM(sav)) | if (SAV_ISGCM(sav)) | ||||
crda->crd_len = 8; /* RFC4106 5, SPI + SN */ | crda->crd_len = 8; /* RFC4106 5, SPI + SN */ | ||||
else | else | ||||
Show All 30 Lines | esp_output_cb(struct cryptop *crp) | ||||
sav = xd->sav; | sav = xd->sav; | ||||
idx = xd->idx; | idx = xd->idx; | ||||
cryptoid = xd->cryptoid; | cryptoid = xd->cryptoid; | ||||
/* Check for crypto errors. */ | /* Check for crypto errors. */ | ||||
if (crp->crp_etype) { | if (crp->crp_etype) { | ||||
if (crp->crp_etype == EAGAIN) { | if (crp->crp_etype == EAGAIN) { | ||||
/* Reset the session ID */ | /* Reset the session ID */ | ||||
if (ipsec_updateid(sav, &crp->crp_sid, &cryptoid) != 0) | if (ipsec_updateid(sav, &crp->crp_session, &cryptoid) != 0) | ||||
crypto_freesession(cryptoid); | crypto_freesession(cryptoid); | ||||
xd->cryptoid = crp->crp_sid; | xd->cryptoid = crp->crp_session; | ||||
CURVNET_RESTORE(); | CURVNET_RESTORE(); | ||||
return (crypto_dispatch(crp)); | return (crypto_dispatch(crp)); | ||||
} | } | ||||
ESPSTAT_INC(esps_noxform); | ESPSTAT_INC(esps_noxform); | ||||
DPRINTF(("%s: crypto error %d\n", __func__, crp->crp_etype)); | DPRINTF(("%s: crypto error %d\n", __func__, crp->crp_etype)); | ||||
error = crp->crp_etype; | error = crp->crp_etype; | ||||
m_freem(m); | m_freem(m); | ||||
goto bad; | goto bad; | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |