Changeset View
Changeset View
Standalone View
Standalone View
sys/opencrypto/crypto.c
Show First 20 Lines • Show All 573 Lines • ▼ Show 20 Lines | crypto_cipher(const struct crypto_session_params *csp) | ||||
case CRYPTO_NULL_CBC: | case CRYPTO_NULL_CBC: | ||||
return (&enc_xform_null); | return (&enc_xform_null); | ||||
case CRYPTO_CHACHA20: | case CRYPTO_CHACHA20: | ||||
return (&enc_xform_chacha20); | return (&enc_xform_chacha20); | ||||
case CRYPTO_AES_CCM_16: | case CRYPTO_AES_CCM_16: | ||||
return (&enc_xform_ccm); | return (&enc_xform_ccm); | ||||
case CRYPTO_CHACHA20_POLY1305: | case CRYPTO_CHACHA20_POLY1305: | ||||
return (&enc_xform_chacha20_poly1305); | return (&enc_xform_chacha20_poly1305); | ||||
case CRYPTO_XCHACHA20_POLY1305: | |||||
return (&enc_xform_xchacha20_poly1305); | |||||
default: | default: | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
} | } | ||||
static struct cryptocap * | static struct cryptocap * | ||||
crypto_checkdriver(uint32_t hid) | crypto_checkdriver(uint32_t hid) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | static enum alg_type { | ||||
[CRYPTO_SHA2_224] = ALG_DIGEST, | [CRYPTO_SHA2_224] = ALG_DIGEST, | ||||
[CRYPTO_SHA2_256] = ALG_DIGEST, | [CRYPTO_SHA2_256] = ALG_DIGEST, | ||||
[CRYPTO_SHA2_384] = ALG_DIGEST, | [CRYPTO_SHA2_384] = ALG_DIGEST, | ||||
[CRYPTO_SHA2_512] = ALG_DIGEST, | [CRYPTO_SHA2_512] = ALG_DIGEST, | ||||
[CRYPTO_POLY1305] = ALG_KEYED_DIGEST, | [CRYPTO_POLY1305] = ALG_KEYED_DIGEST, | ||||
[CRYPTO_AES_CCM_CBC_MAC] = ALG_KEYED_DIGEST, | [CRYPTO_AES_CCM_CBC_MAC] = ALG_KEYED_DIGEST, | ||||
[CRYPTO_AES_CCM_16] = ALG_AEAD, | [CRYPTO_AES_CCM_16] = ALG_AEAD, | ||||
[CRYPTO_CHACHA20_POLY1305] = ALG_AEAD, | [CRYPTO_CHACHA20_POLY1305] = ALG_AEAD, | ||||
[CRYPTO_XCHACHA20_POLY1305] = ALG_AEAD, | |||||
}; | }; | ||||
static enum alg_type | static enum alg_type | ||||
alg_type(int alg) | alg_type(int alg) | ||||
{ | { | ||||
if (alg < nitems(alg_types)) | if (alg < nitems(alg_types)) | ||||
return (alg_types[alg]); | return (alg_types[alg]); | ||||
▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | case CRYPTO_AES_NIST_GCM_16: | ||||
if (csp->csp_auth_mlen > AES_GMAC_HASH_LEN) | if (csp->csp_auth_mlen > AES_GMAC_HASH_LEN) | ||||
return (false); | return (false); | ||||
if (csp->csp_ivlen != AES_GCM_IV_LEN) | if (csp->csp_ivlen != AES_GCM_IV_LEN) | ||||
return (false); | return (false); | ||||
break; | break; | ||||
case CRYPTO_CHACHA20_POLY1305: | case CRYPTO_CHACHA20_POLY1305: | ||||
if (csp->csp_ivlen != 8 && csp->csp_ivlen != 12) | if (csp->csp_ivlen != 8 && csp->csp_ivlen != 12) | ||||
return (false); | |||||
if (csp->csp_auth_mlen > POLY1305_HASH_LEN) | |||||
return (false); | |||||
break; | |||||
case CRYPTO_XCHACHA20_POLY1305: | |||||
if (csp->csp_ivlen != XCHACHA20_POLY1305_IV_LEN) | |||||
return (false); | return (false); | ||||
if (csp->csp_auth_mlen > POLY1305_HASH_LEN) | if (csp->csp_auth_mlen > POLY1305_HASH_LEN) | ||||
return (false); | return (false); | ||||
break; | break; | ||||
} | } | ||||
break; | break; | ||||
case CSP_MODE_ETA: | case CSP_MODE_ETA: | ||||
if (!alg_is_cipher(csp->csp_cipher_alg)) | if (!alg_is_cipher(csp->csp_cipher_alg)) | ||||
▲ Show 20 Lines • Show All 1,121 Lines • Show Last 20 Lines |