examples/vhost: fix use after free on drain
[dpdk.git] / drivers / crypto / aesni_mb / rte_aesni_mb_pmd_ops.c
index ed93dae..48a8f91 100644 (file)
@@ -8,7 +8,7 @@
 #include <rte_common.h>
 #include <rte_malloc.h>
 #include <rte_ether.h>
-#include <rte_cryptodev_pmd.h>
+#include <cryptodev_pmd.h>
 
 #include "aesni_mb_pmd_private.h"
 
@@ -400,8 +400,13 @@ static const struct rte_cryptodev_capabilities aesni_mb_pmd_capabilities[] = {
                                .block_size = 16,
                                .key_size = {
                                        .min = 16,
+#if IMB_VERSION(0, 54, 2) <= IMB_VERSION_NUM
+                                       .max = 32,
+                                       .increment = 16
+#else
                                        .max = 16,
                                        .increment = 0
+#endif
                                },
                                .digest_size = {
                                        .min = 4,
@@ -455,9 +460,9 @@ static const struct rte_cryptodev_capabilities aesni_mb_pmd_capabilities[] = {
                                        .increment = 8
                                },
                                .digest_size = {
-                                       .min = 8,
+                                       .min = 1,
                                        .max = 16,
-                                       .increment = 4
+                                       .increment = 1
                                },
                                .aad_size = {
                                        .min = 0,
@@ -485,9 +490,9 @@ static const struct rte_cryptodev_capabilities aesni_mb_pmd_capabilities[] = {
                                        .increment = 8
                                },
                                .digest_size = {
-                                       .min = 8,
+                                       .min = 1,
                                        .max = 16,
-                                       .increment = 4
+                                       .increment = 1
                                },
                                .iv_size = {
                                        .min = 12,
@@ -497,6 +502,189 @@ static const struct rte_cryptodev_capabilities aesni_mb_pmd_capabilities[] = {
                        }, }
                }, }
        },
+#if IMB_VERSION(0, 53, 0) <= IMB_VERSION_NUM
+       {       /* AES ECB */
+               .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+               {.sym = {
+                       .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
+                       {.cipher = {
+                               .algo = RTE_CRYPTO_CIPHER_AES_ECB,
+                               .block_size = 16,
+                               .key_size = {
+                                       .min = 16,
+                                       .max = 32,
+                                       .increment = 8
+                               },
+                               .iv_size = { 0 }
+                       }, }
+               }, }
+       },
+#endif
+#if IMB_VERSION(0, 53, 3) <= IMB_VERSION_NUM
+       {       /* ZUC (EIA3) */
+               .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+               {.sym = {
+                       .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
+                       {.auth = {
+                               .algo = RTE_CRYPTO_AUTH_ZUC_EIA3,
+                               .block_size = 16,
+                               .key_size = {
+                                       .min = 16,
+                                       .max = 16,
+                                       .increment = 0
+                               },
+                               .digest_size = {
+                                       .min = 4,
+                                       .max = 4,
+                                       .increment = 0
+                               },
+                               .iv_size = {
+                                       .min = 16,
+                                       .max = 16,
+                                       .increment = 0
+                               }
+                       }, }
+               }, }
+       },
+       {       /* ZUC (EEA3) */
+               .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+               {.sym = {
+                       .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
+                       {.cipher = {
+                               .algo = RTE_CRYPTO_CIPHER_ZUC_EEA3,
+                               .block_size = 16,
+                               .key_size = {
+                                       .min = 16,
+                                       .max = 16,
+                                       .increment = 0
+                               },
+                               .iv_size = {
+                                       .min = 16,
+                                       .max = 16,
+                                       .increment = 0
+                               },
+                       }, }
+               }, }
+       },
+       {       /* SNOW 3G (UIA2) */
+               .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+               {.sym = {
+                       .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
+                       {.auth = {
+                               .algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2,
+                               .block_size = 16,
+                               .key_size = {
+                                       .min = 16,
+                                       .max = 16,
+                                       .increment = 0
+                               },
+                               .digest_size = {
+                                       .min = 4,
+                                       .max = 4,
+                                       .increment = 0
+                               },
+                               .iv_size = {
+                                       .min = 16,
+                                       .max = 16,
+                                       .increment = 0
+                               }
+                       }, }
+               }, }
+       },
+       {       /* SNOW 3G (UEA2) */
+               .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+               {.sym = {
+                       .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
+                       {.cipher = {
+                               .algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
+                               .block_size = 16,
+                               .key_size = {
+                                       .min = 16,
+                                       .max = 16,
+                                       .increment = 0
+                               },
+                               .iv_size = {
+                                       .min = 16,
+                                       .max = 16,
+                                       .increment = 0
+                               }
+                       }, }
+               }, }
+       },
+       {       /* KASUMI (F9) */
+               .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+               {.sym = {
+                       .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
+                       {.auth = {
+                               .algo = RTE_CRYPTO_AUTH_KASUMI_F9,
+                               .block_size = 8,
+                               .key_size = {
+                                       .min = 16,
+                                       .max = 16,
+                                       .increment = 0
+                               },
+                               .digest_size = {
+                                       .min = 4,
+                                       .max = 4,
+                                       .increment = 0
+                               },
+                               .iv_size = { 0 }
+                       }, }
+               }, }
+       },
+       {       /* KASUMI (F8) */
+               .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+               {.sym = {
+                       .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
+                       {.cipher = {
+                               .algo = RTE_CRYPTO_CIPHER_KASUMI_F8,
+                               .block_size = 8,
+                               .key_size = {
+                                       .min = 16,
+                                       .max = 16,
+                                       .increment = 0
+                               },
+                               .iv_size = {
+                                       .min = 8,
+                                       .max = 8,
+                                       .increment = 0
+                               }
+                       }, }
+               }, }
+       },
+#endif
+#if IMB_VERSION(0, 54, 3) <= IMB_VERSION_NUM
+       {       /* CHACHA20-POLY1305 */
+               .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+               {.sym = {
+                       .xform_type = RTE_CRYPTO_SYM_XFORM_AEAD,
+                       {.aead = {
+                               .algo = RTE_CRYPTO_AEAD_CHACHA20_POLY1305,
+                               .block_size = 64,
+                               .key_size = {
+                                       .min = 32,
+                                       .max = 32,
+                                       .increment = 0
+                               },
+                               .digest_size = {
+                                       .min = 16,
+                                       .max = 16,
+                                       .increment = 0
+                               },
+                               .aad_size = {
+                                       .min = 0,
+                                       .max = 240,
+                                       .increment = 1
+                               },
+                               .iv_size = {
+                                       .min = 12,
+                                       .max = 12,
+                                       .increment = 0
+                               },
+                       }, }
+               }, }
+       },
+#endif
        RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
 };
 
@@ -875,16 +1063,17 @@ aesni_mb_pmd_sec_sess_create(void *dev, struct rte_security_session_conf *conf,
        struct rte_cryptodev *cdev = (struct rte_cryptodev *)dev;
        int ret;
 
+       if (conf->action_type != RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL ||
+                       conf->protocol != RTE_SECURITY_PROTOCOL_DOCSIS) {
+               AESNI_MB_LOG(ERR, "Invalid security protocol");
+               return -EINVAL;
+       }
+
        if (rte_mempool_get(mempool, &sess_private_data)) {
                AESNI_MB_LOG(ERR, "Couldn't get object from session mempool");
                return -ENOMEM;
        }
 
-       if (conf->protocol != RTE_SECURITY_PROTOCOL_DOCSIS) {
-               AESNI_MB_LOG(ERR, "Invalid security protocol");
-               return -EINVAL;
-       }
-
        ret = aesni_mb_set_docsis_sec_session_parameters(cdev, conf,
                        sess_private_data);
 
@@ -910,7 +1099,7 @@ aesni_mb_pmd_sec_sess_destroy(void *dev __rte_unused,
 
        if (sess_priv) {
                struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv);
-               memset(sess, 0, sizeof(struct aesni_mb_session));
+               memset(sess_priv, 0, sizeof(struct aesni_mb_session));
                set_sec_session_private_data(sess, NULL);
                rte_mempool_put(sess_mp, sess_priv);
        }