Changeset View
Changeset View
Standalone View
Standalone View
head/sys/opencrypto/cryptosoft.c
Show First 20 Lines • Show All 321 Lines • ▼ Show 20 Lines | swcr_authcompute(struct swcr_session *ses, struct cryptop *crp) | ||||
struct auth_hash *axf; | struct auth_hash *axf; | ||||
union authctx ctx; | union authctx ctx; | ||||
int err; | int err; | ||||
sw = &ses->swcr_auth; | sw = &ses->swcr_auth; | ||||
axf = sw->sw_axf; | axf = sw->sw_axf; | ||||
if (crp->crp_auth_key != NULL) { | |||||
csp = crypto_get_params(crp->crp_session); | csp = crypto_get_params(crp->crp_session); | ||||
if (crp->crp_auth_key != NULL) { | |||||
swcr_authprepare(axf, sw, crp->crp_auth_key, | swcr_authprepare(axf, sw, crp->crp_auth_key, | ||||
csp->csp_auth_klen); | csp->csp_auth_klen); | ||||
} | } | ||||
bcopy(sw->sw_ictx, &ctx, axf->ctxsize); | bcopy(sw->sw_ictx, &ctx, axf->ctxsize); | ||||
if (crp->crp_aad != NULL) | if (crp->crp_aad != NULL) | ||||
err = axf->Update(&ctx, crp->crp_aad, crp->crp_aad_length); | err = axf->Update(&ctx, crp->crp_aad, crp->crp_aad_length); | ||||
Show All 9 Lines | err = crypto_apply_buf(&crp->crp_obuf, | ||||
crp->crp_payload_output_start, crp->crp_payload_length, | crp->crp_payload_output_start, crp->crp_payload_length, | ||||
axf->Update, &ctx); | axf->Update, &ctx); | ||||
else | else | ||||
err = crypto_apply(crp, crp->crp_payload_start, | err = crypto_apply(crp, crp->crp_payload_start, | ||||
crp->crp_payload_length, axf->Update, &ctx); | crp->crp_payload_length, axf->Update, &ctx); | ||||
if (err) | if (err) | ||||
goto out; | goto out; | ||||
if (csp->csp_flags & CSP_F_ESN) | |||||
axf->Update(&ctx, crp->crp_esn, 4); | |||||
axf->Final(aalg, &ctx); | axf->Final(aalg, &ctx); | ||||
if (sw->sw_octx != NULL) { | if (sw->sw_octx != NULL) { | ||||
bcopy(sw->sw_octx, &ctx, axf->ctxsize); | bcopy(sw->sw_octx, &ctx, axf->ctxsize); | ||||
axf->Update(&ctx, aalg, axf->hashsize); | axf->Update(&ctx, aalg, axf->hashsize); | ||||
axf->Final(aalg, &ctx); | axf->Final(aalg, &ctx); | ||||
} | } | ||||
if (crp->crp_op & CRYPTO_OP_VERIFY_DIGEST) { | if (crp->crp_op & CRYPTO_OP_VERIFY_DIGEST) { | ||||
▲ Show 20 Lines • Show All 865 Lines • ▼ Show 20 Lines | swcr_cipher_supported(const struct crypto_session_params *csp) | ||||
if (txf == NULL) | if (txf == NULL) | ||||
return (false); | return (false); | ||||
if (csp->csp_cipher_alg != CRYPTO_NULL_CBC && | if (csp->csp_cipher_alg != CRYPTO_NULL_CBC && | ||||
txf->ivsize != csp->csp_ivlen) | txf->ivsize != csp->csp_ivlen) | ||||
return (false); | return (false); | ||||
return (true); | return (true); | ||||
} | } | ||||
#define SUPPORTED_SES (CSP_F_SEPARATE_OUTPUT | CSP_F_SEPARATE_AAD | CSP_F_ESN) | |||||
static int | static int | ||||
swcr_probesession(device_t dev, const struct crypto_session_params *csp) | swcr_probesession(device_t dev, const struct crypto_session_params *csp) | ||||
{ | { | ||||
if ((csp->csp_flags & ~(SUPPORTED_SES)) != 0) | |||||
if ((csp->csp_flags & ~(CSP_F_SEPARATE_OUTPUT | CSP_F_SEPARATE_AAD)) != | |||||
0) | |||||
return (EINVAL); | return (EINVAL); | ||||
switch (csp->csp_mode) { | switch (csp->csp_mode) { | ||||
case CSP_MODE_COMPRESS: | case CSP_MODE_COMPRESS: | ||||
switch (csp->csp_cipher_alg) { | switch (csp->csp_cipher_alg) { | ||||
case CRYPTO_DEFLATE_COMP: | case CRYPTO_DEFLATE_COMP: | ||||
break; | break; | ||||
default: | default: | ||||
return (EINVAL); | return (EINVAL); | ||||
▲ Show 20 Lines • Show All 258 Lines • Show Last 20 Lines |