The cryptodev API does not check for user parameters being within the
bounds of what the driver supports. Currently, the only key size supported
by ixgbe is 16 bytes, so that is what we will check for. Add the check.

Signed-off-by: Anatoly Burakov <[email protected]>
---
 drivers/net/intel/ixgbe/ixgbe_ipsec.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/intel/ixgbe/ixgbe_ipsec.c 
b/drivers/net/intel/ixgbe/ixgbe_ipsec.c
index bdd34344e8..aaf657af5f 100644
--- a/drivers/net/intel/ixgbe/ixgbe_ipsec.c
+++ b/drivers/net/intel/ixgbe/ixgbe_ipsec.c
@@ -384,6 +384,12 @@ ixgbe_crypto_create_session(void *device,
        }
        aead_xform = &conf->crypto_xform->aead;
 
+       /* Only 16-byte keys are supported. */
+       if (aead_xform->key.length != 16) {
+               PMD_DRV_LOG(ERR, "Unsupported key length %u", 
aead_xform->key.length);
+               return -ENOTSUP;
+       }
+
        if (conf->ipsec.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) {
                if (dev_conf->rxmode.offloads & RTE_ETH_RX_OFFLOAD_SECURITY) {
                        ic_session->op = IXGBE_OP_AUTHENTICATED_DECRYPTION;
-- 
2.52.0

Reply via email to