Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netipsec/xform_ah.c
Show First 20 Lines • Show All 230 Lines • ▼ Show 20 Lines | |||||
static int | static int | ||||
ah_init(struct secasvar *sav, struct xformsw *xsp) | ah_init(struct secasvar *sav, struct xformsw *xsp) | ||||
{ | { | ||||
struct crypto_session_params csp; | struct crypto_session_params csp; | ||||
int error; | int error; | ||||
memset(&csp, 0, sizeof(csp)); | memset(&csp, 0, sizeof(csp)); | ||||
csp.csp_mode = CSP_MODE_DIGEST; | csp.csp_mode = CSP_MODE_DIGEST; | ||||
if (sav->flags & SADB_X_SAFLAGS_ESN) | |||||
csp.csp_flags |= CSP_F_ESN; | |||||
error = ah_init0(sav, xsp, &csp); | error = ah_init0(sav, xsp, &csp); | ||||
return error ? error : | return error ? error : | ||||
crypto_newsession(&sav->tdb_cryptoid, &csp, V_crypto_support); | crypto_newsession(&sav->tdb_cryptoid, &csp, V_crypto_support); | ||||
} | } | ||||
static void | static void | ||||
ah_cleanup(struct secasvar *sav) | ah_cleanup(struct secasvar *sav) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 402 Lines • ▼ Show 20 Lines | ah_input(struct mbuf *m, struct secasvar *sav, int skip, int protoff) | ||||
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) | if (V_async_crypto) | ||||
crp->crp_flags |= CRYPTO_F_ASYNC | CRYPTO_F_ASYNC_KEEPORDER; | 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 && | |||||
sav->replay != NULL && sav->replay->wsize != 0) { | |||||
seqh = htonl(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; | ||||
return (crypto_dispatch(crp)); | return (crypto_dispatch(crp)); | ||||
▲ Show 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | ah_output(struct mbuf *m, struct secpolicy *sp, struct secasvar *sav, | ||||
struct xform_data *xd; | struct xform_data *xd; | ||||
struct mbuf *mi; | struct mbuf *mi; | ||||
struct cryptop *crp; | struct cryptop *crp; | ||||
struct newah *ah; | struct newah *ah; | ||||
crypto_session_t cryptoid; | crypto_session_t cryptoid; | ||||
uint16_t iplen; | uint16_t iplen; | ||||
int error, rplen, authsize, ahsize, maxpacketsize, roff; | int error, rplen, authsize, ahsize, maxpacketsize, roff; | ||||
uint8_t prot; | uint8_t prot; | ||||
uint32_t seqh; | |||||
IPSEC_ASSERT(sav != NULL, ("null SA")); | IPSEC_ASSERT(sav != NULL, ("null SA")); | ||||
ahx = sav->tdb_authalgxform; | ahx = sav->tdb_authalgxform; | ||||
IPSEC_ASSERT(ahx != NULL, ("null authentication xform")); | IPSEC_ASSERT(ahx != NULL, ("null authentication xform")); | ||||
AHSTAT_INC(ahs_output); | AHSTAT_INC(ahs_output); | ||||
/* Figure out header size. */ | /* Figure out header size. */ | ||||
▲ Show 20 Lines • Show All 180 Lines • ▼ Show 20 Lines | #endif /* INET6 */ | ||||
/* 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) | if (V_async_crypto) | ||||
crp->crp_flags |= CRYPTO_F_ASYNC | CRYPTO_F_ASYNC_KEEPORDER; | 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) { | |||||
seqh = htonl((uint32_t)(sav->replay->count >> IPSEC_SEQH_SHIFT)); | |||||
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; | ||||
▲ Show 20 Lines • Show All 108 Lines • Show Last 20 Lines |