Changeset View
Changeset View
Standalone View
Standalone View
sys/netipsec/xform_ah.c
Show First 20 Lines • Show All 646 Lines • ▼ Show 20 Lines | if (error != 0) { | ||||
crypto_freereq(crp); | crypto_freereq(crp); | ||||
key_freesav(&sav); | key_freesav(&sav); | ||||
return (error); | return (error); | ||||
} | } | ||||
/* Crypto operation descriptor. */ | /* Crypto operation descriptor. */ | ||||
crp->crp_op = CRYPTO_OP_COMPUTE_DIGEST; | crp->crp_op = CRYPTO_OP_COMPUTE_DIGEST; | ||||
crp->crp_flags = CRYPTO_F_CBIFSYNC; | crp->crp_flags = CRYPTO_F_CBIFSYNC; | ||||
if (V_async_crypto) | |||||
crp->crp_flags |= CRYPTO_F_ASYNC | CRYPTO_F_ASYNC_KEEPORDER; | |||||
crypto_use_mbuf(crp, m); | crypto_use_mbuf(crp, m); | ||||
crp->crp_callback = ah_input_cb; | crp->crp_callback = ah_input_cb; | ||||
crp->crp_opaque = xd; | crp->crp_opaque = xd; | ||||
if (sav->flags & SADB_X_SAFLAGS_ESN && | if (sav->flags & SADB_X_SAFLAGS_ESN && | ||||
sav->replay != NULL && sav->replay->wsize != 0) { | sav->replay != NULL && sav->replay->wsize != 0) { | ||||
seqh = htonl(seqh); | seqh = htonl(seqh); | ||||
memcpy(crp->crp_esn, &seqh, sizeof(seqh)); | memcpy(crp->crp_esn, &seqh, sizeof(seqh)); | ||||
} | } | ||||
/* These are passed as-is to the callback. */ | /* These are passed as-is to the callback. */ | ||||
xd->sav = sav; | xd->sav = sav; | ||||
xd->nxt = hl; | xd->nxt = hl; | ||||
xd->protoff = protoff; | xd->protoff = protoff; | ||||
xd->skip = skip; | xd->skip = skip; | ||||
xd->cryptoid = cryptoid; | xd->cryptoid = cryptoid; | ||||
xd->vnet = curvnet; | xd->vnet = curvnet; | ||||
if (V_async_crypto) | |||||
return (crypto_dispatch_async(crp, CRYPTO_ASYNC_ORDERED)); | |||||
else | |||||
return (crypto_dispatch(crp)); | return (crypto_dispatch(crp)); | ||||
bad: | bad: | ||||
m_freem(m); | m_freem(m); | ||||
key_freesav(&sav); | key_freesav(&sav); | ||||
return (error); | return (error); | ||||
} | } | ||||
/* | /* | ||||
* AH input callback from the crypto driver. | * AH input callback from the crypto driver. | ||||
▲ Show 20 Lines • Show All 348 Lines • ▼ Show 20 Lines | if (error != 0) { | ||||
free(xd, M_XDATA); | free(xd, M_XDATA); | ||||
crypto_freereq(crp); | crypto_freereq(crp); | ||||
goto bad; | goto bad; | ||||
} | } | ||||
/* Crypto operation descriptor. */ | /* Crypto operation descriptor. */ | ||||
crp->crp_op = CRYPTO_OP_COMPUTE_DIGEST; | crp->crp_op = CRYPTO_OP_COMPUTE_DIGEST; | ||||
crp->crp_flags = CRYPTO_F_CBIFSYNC; | crp->crp_flags = CRYPTO_F_CBIFSYNC; | ||||
if (V_async_crypto) | |||||
crp->crp_flags |= CRYPTO_F_ASYNC | CRYPTO_F_ASYNC_KEEPORDER; | |||||
crypto_use_mbuf(crp, m); | crypto_use_mbuf(crp, m); | ||||
crp->crp_callback = ah_output_cb; | crp->crp_callback = ah_output_cb; | ||||
crp->crp_opaque = xd; | crp->crp_opaque = xd; | ||||
if (sav->flags & SADB_X_SAFLAGS_ESN && sav->replay != NULL) { | if (sav->flags & SADB_X_SAFLAGS_ESN && sav->replay != NULL) { | ||||
seqh = htonl((uint32_t)(sav->replay->count >> IPSEC_SEQH_SHIFT)); | seqh = htonl((uint32_t)(sav->replay->count >> IPSEC_SEQH_SHIFT)); | ||||
memcpy(crp->crp_esn, &seqh, sizeof(seqh)); | memcpy(crp->crp_esn, &seqh, sizeof(seqh)); | ||||
} | } | ||||
/* These are passed as-is to the callback. */ | /* These are passed as-is to the callback. */ | ||||
xd->sp = sp; | xd->sp = sp; | ||||
xd->sav = sav; | xd->sav = sav; | ||||
xd->skip = skip; | xd->skip = skip; | ||||
xd->idx = idx; | xd->idx = idx; | ||||
xd->cryptoid = cryptoid; | xd->cryptoid = cryptoid; | ||||
xd->vnet = curvnet; | xd->vnet = curvnet; | ||||
return crypto_dispatch(crp); | if (V_async_crypto) | ||||
return (crypto_dispatch_async(crp, CRYPTO_ASYNC_ORDERED)); | |||||
else | |||||
return (crypto_dispatch(crp)); | |||||
bad: | bad: | ||||
if (m) | if (m) | ||||
m_freem(m); | m_freem(m); | ||||
key_freesav(&sav); | key_freesav(&sav); | ||||
key_freesp(&sp); | key_freesp(&sp); | ||||
return (error); | return (error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 98 Lines • Show Last 20 Lines |