crypto: Validate AES-GCM IV length in check_csp().
This centralizes the check for valid nonce lengths for AES-GCM. While here, remove some duplicate checks for valid AES-GCM tag lengths from ccp(4) and ccr(4). Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33194
This commit is contained in:
parent
ec498562b7
commit
6e17a2e00d
@ -305,8 +305,7 @@ aesni_probesession(device_t dev, const struct crypto_session_params *csp)
|
||||
if (csp->csp_auth_mlen != 0 &&
|
||||
csp->csp_auth_mlen != GMAC_DIGEST_LEN)
|
||||
return (EINVAL);
|
||||
if (csp->csp_ivlen != AES_GCM_IV_LEN ||
|
||||
!sc->has_aes)
|
||||
if (!sc->has_aes)
|
||||
return (EINVAL);
|
||||
break;
|
||||
case CRYPTO_AES_CCM_16:
|
||||
|
@ -217,8 +217,6 @@ armv8_crypto_probesession(device_t dev,
|
||||
case CRYPTO_AES_NIST_GCM_16:
|
||||
if (!sc->has_pmul)
|
||||
return (EINVAL);
|
||||
if (csp->csp_ivlen != AES_GCM_IV_LEN)
|
||||
return (EINVAL);
|
||||
if (csp->csp_auth_mlen != 0 &&
|
||||
csp->csp_auth_mlen != GMAC_DIGEST_LEN)
|
||||
return (EINVAL);
|
||||
|
@ -378,11 +378,6 @@ ccp_probesession(device_t dev, const struct crypto_session_params *csp)
|
||||
case CSP_MODE_AEAD:
|
||||
switch (csp->csp_cipher_alg) {
|
||||
case CRYPTO_AES_NIST_GCM_16:
|
||||
if (csp->csp_ivlen != AES_GCM_IV_LEN)
|
||||
return (EINVAL);
|
||||
if (csp->csp_auth_mlen < 0 ||
|
||||
csp->csp_auth_mlen > AES_GMAC_HASH_LEN)
|
||||
return (EINVAL);
|
||||
if ((sc->hw_features & VERSION_CAP_AES) == 0)
|
||||
return (EINVAL);
|
||||
break;
|
||||
|
@ -2540,12 +2540,6 @@ ccr_probesession(device_t dev, const struct crypto_session_params *csp)
|
||||
case CSP_MODE_AEAD:
|
||||
switch (csp->csp_cipher_alg) {
|
||||
case CRYPTO_AES_NIST_GCM_16:
|
||||
if (csp->csp_ivlen != AES_GCM_IV_LEN)
|
||||
return (EINVAL);
|
||||
if (csp->csp_auth_mlen < 0 ||
|
||||
csp->csp_auth_mlen > AES_GMAC_HASH_LEN)
|
||||
return (EINVAL);
|
||||
break;
|
||||
case CRYPTO_AES_CCM_16:
|
||||
break;
|
||||
default:
|
||||
|
@ -1911,8 +1911,6 @@ qat_probesession(device_t dev, const struct crypto_session_params *csp)
|
||||
case CSP_MODE_AEAD:
|
||||
switch (csp->csp_cipher_alg) {
|
||||
case CRYPTO_AES_NIST_GCM_16:
|
||||
if (csp->csp_ivlen != AES_GCM_IV_LEN)
|
||||
return EINVAL;
|
||||
break;
|
||||
default:
|
||||
return EINVAL;
|
||||
|
@ -2304,9 +2304,6 @@ safexcel_probesession(device_t dev, const struct crypto_session_params *csp)
|
||||
case CSP_MODE_AEAD:
|
||||
switch (csp->csp_cipher_alg) {
|
||||
case CRYPTO_AES_NIST_GCM_16:
|
||||
if (csp->csp_ivlen != AES_GCM_IV_LEN)
|
||||
return (EINVAL);
|
||||
break;
|
||||
case CRYPTO_AES_CCM_16:
|
||||
break;
|
||||
default:
|
||||
|
@ -851,7 +851,10 @@ check_csp(const struct crypto_session_params *csp)
|
||||
return (false);
|
||||
break;
|
||||
case CRYPTO_AES_NIST_GCM_16:
|
||||
if (csp->csp_auth_mlen > 16)
|
||||
if (csp->csp_auth_mlen > AES_GMAC_HASH_LEN)
|
||||
return (false);
|
||||
|
||||
if (csp->csp_ivlen != AES_GCM_IV_LEN)
|
||||
return (false);
|
||||
break;
|
||||
case CRYPTO_CHACHA20_POLY1305:
|
||||
|
@ -1308,9 +1308,6 @@ swcr_setup_gcm(struct swcr_session *ses,
|
||||
struct swcr_auth *swa;
|
||||
const struct auth_hash *axf;
|
||||
|
||||
if (csp->csp_ivlen != AES_GCM_IV_LEN)
|
||||
return (EINVAL);
|
||||
|
||||
/* First, setup the auth side. */
|
||||
swa = &ses->swcr_auth;
|
||||
switch (csp->csp_cipher_klen * 8) {
|
||||
|
Loading…
Reference in New Issue
Block a user