Changeset View
Changeset View
Standalone View
Standalone View
sys/opencrypto/crypto.c
Show First 20 Lines • Show All 483 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
const struct crypto_session_params * | const struct crypto_session_params * | ||||
crypto_get_params(crypto_session_t crypto_session) | crypto_get_params(crypto_session_t crypto_session) | ||||
{ | { | ||||
return (&crypto_session->csp); | return (&crypto_session->csp); | ||||
} | } | ||||
struct auth_hash * | const struct auth_hash * | ||||
crypto_auth_hash(const struct crypto_session_params *csp) | crypto_auth_hash(const struct crypto_session_params *csp) | ||||
{ | { | ||||
switch (csp->csp_auth_alg) { | switch (csp->csp_auth_alg) { | ||||
case CRYPTO_SHA1_HMAC: | case CRYPTO_SHA1_HMAC: | ||||
return (&auth_hash_hmac_sha1); | return (&auth_hash_hmac_sha1); | ||||
case CRYPTO_SHA2_224_HMAC: | case CRYPTO_SHA2_224_HMAC: | ||||
return (&auth_hash_hmac_sha2_224); | return (&auth_hash_hmac_sha2_224); | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | case CRYPTO_AES_CCM_CBC_MAC: | ||||
default: | default: | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
default: | default: | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
} | } | ||||
struct enc_xform * | const struct enc_xform * | ||||
crypto_cipher(const struct crypto_session_params *csp) | crypto_cipher(const struct crypto_session_params *csp) | ||||
{ | { | ||||
switch (csp->csp_cipher_alg) { | switch (csp->csp_cipher_alg) { | ||||
case CRYPTO_RIJNDAEL128_CBC: | case CRYPTO_RIJNDAEL128_CBC: | ||||
return (&enc_xform_rijndael128); | return (&enc_xform_rijndael128); | ||||
case CRYPTO_AES_XTS: | case CRYPTO_AES_XTS: | ||||
return (&enc_xform_aes_xts); | return (&enc_xform_aes_xts); | ||||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
#define SUPPORTED_SES (CSP_F_SEPARATE_OUTPUT | CSP_F_SEPARATE_AAD | CSP_F_ESN) | #define SUPPORTED_SES (CSP_F_SEPARATE_OUTPUT | CSP_F_SEPARATE_AAD | CSP_F_ESN) | ||||
/* Various sanity checks on crypto session parameters. */ | /* Various sanity checks on crypto session parameters. */ | ||||
static bool | static bool | ||||
check_csp(const struct crypto_session_params *csp) | check_csp(const struct crypto_session_params *csp) | ||||
{ | { | ||||
struct auth_hash *axf; | const struct auth_hash *axf; | ||||
/* Mode-independent checks. */ | /* Mode-independent checks. */ | ||||
if ((csp->csp_flags & ~(SUPPORTED_SES)) != 0) | if ((csp->csp_flags & ~(SUPPORTED_SES)) != 0) | ||||
return (false); | return (false); | ||||
if (csp->csp_ivlen < 0 || csp->csp_cipher_klen < 0 || | if (csp->csp_ivlen < 0 || csp->csp_cipher_klen < 0 || | ||||
csp->csp_auth_klen < 0 || csp->csp_auth_mlen < 0) | csp->csp_auth_klen < 0 || csp->csp_auth_mlen < 0) | ||||
return (false); | return (false); | ||||
if (csp->csp_auth_key != NULL && csp->csp_auth_klen == 0) | if (csp->csp_auth_key != NULL && csp->csp_auth_klen == 0) | ||||
▲ Show 20 Lines • Show All 1,188 Lines • Show Last 20 Lines |