Changeset View
Changeset View
Standalone View
Standalone View
sys/crypto/aesni/aesni.c
Show First 20 Lines • Show All 247 Lines • ▼ Show 20 Lines | case CRYPTO_AES_XTS: | ||||
if (csp->csp_ivlen != AES_XTS_IV_LEN) | if (csp->csp_ivlen != AES_XTS_IV_LEN) | ||||
return (false); | return (false); | ||||
return (sc->has_aes); | return (sc->has_aes); | ||||
default: | default: | ||||
return (false); | return (false); | ||||
} | } | ||||
} | } | ||||
#define SUPPORTED_SES (CSP_F_SEPARATE_OUTPUT | CSP_F_SEPARATE_AAD | CSP_F_ESN) | |||||
jhb: I'd probably just leave this spelled out in probesession. | |||||
static int | static int | ||||
aesni_probesession(device_t dev, const struct crypto_session_params *csp) | aesni_probesession(device_t dev, const struct crypto_session_params *csp) | ||||
{ | { | ||||
struct aesni_softc *sc; | struct aesni_softc *sc; | ||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
if ((csp->csp_flags & ~(CSP_F_SEPARATE_OUTPUT | CSP_F_SEPARATE_AAD)) != | if ((csp->csp_flags & ~(SUPPORTED_SES)) != 0) | ||||
0) | |||||
return (EINVAL); | return (EINVAL); | ||||
switch (csp->csp_mode) { | switch (csp->csp_mode) { | ||||
case CSP_MODE_DIGEST: | case CSP_MODE_DIGEST: | ||||
if (!aesni_auth_supported(sc, csp)) | if (!aesni_auth_supported(sc, csp)) | ||||
return (EINVAL); | return (EINVAL); | ||||
break; | break; | ||||
case CSP_MODE_CIPHER: | case CSP_MODE_CIPHER: | ||||
if (!aesni_cipher_supported(sc, csp)) | if (!aesni_cipher_supported(sc, csp)) | ||||
▲ Show 20 Lines • Show All 591 Lines • ▼ Show 20 Lines | if (CRYPTO_HAS_OUTPUT_BUFFER(crp) && | ||||
CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) | CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) | ||||
crypto_apply_buf(&crp->crp_obuf, | crypto_apply_buf(&crp->crp_obuf, | ||||
crp->crp_payload_output_start, | crp->crp_payload_output_start, | ||||
crp->crp_payload_length, | crp->crp_payload_length, | ||||
ses->hash_update, &sctx); | ses->hash_update, &sctx); | ||||
else | else | ||||
crypto_apply(crp, crp->crp_payload_start, | crypto_apply(crp, crp->crp_payload_start, | ||||
crp->crp_payload_length, ses->hash_update, &sctx); | crp->crp_payload_length, ses->hash_update, &sctx); | ||||
if (csp->csp_flags & CSP_F_ESN) | |||||
jhbUnsubmitted Not Done Inline ActionsWoo, nice it was this easy to add! jhb: Woo, nice it was this easy to add! | |||||
ses->hash_update(&sctx, crp->crp_esn, 4); | |||||
ses->hash_finalize(res, &sctx); | ses->hash_finalize(res, &sctx); | ||||
/* Outer hash: (K ^ OPAD) || inner hash */ | /* Outer hash: (K ^ OPAD) || inner hash */ | ||||
ses->hash_init(&sctx); | ses->hash_init(&sctx); | ||||
for (i = 0; i < keylen; i++) | for (i = 0; i < keylen; i++) | ||||
hmac_key[i] = key[i] ^ HMAC_OPAD_VAL; | hmac_key[i] = key[i] ^ HMAC_OPAD_VAL; | ||||
for (i = keylen; i < sizeof(hmac_key); i++) | for (i = keylen; i < sizeof(hmac_key); i++) | ||||
hmac_key[i] = 0 ^ HMAC_OPAD_VAL; | hmac_key[i] = 0 ^ HMAC_OPAD_VAL; | ||||
Show All 39 Lines |
I'd probably just leave this spelled out in probesession.