net/mlx5: fill meter capabilities using DevX
[dpdk.git] / drivers / crypto / snow3g / rte_snow3g_pmd.c
index 5fd94b6..9d07e1a 100644 (file)
@@ -10,7 +10,7 @@
 #include <rte_malloc.h>
 #include <rte_cpuflags.h>
 
-#include "rte_snow3g_pmd_private.h"
+#include "snow3g_pmd_private.h"
 
 #define SNOW3G_IV_LENGTH 16
 #define SNOW3G_MAX_BURST 8
@@ -84,6 +84,8 @@ snow3g_set_session_parameters(struct snow3g_session *sess,
        }
 
        if (cipher_xform) {
+               uint8_t cipher_key[SNOW3G_MAX_KEY_SIZE];
+
                /* Only SNOW 3G UEA2 supported */
                if (cipher_xform->cipher.algo != RTE_CRYPTO_CIPHER_SNOW3G_UEA2)
                        return -ENOTSUP;
@@ -92,14 +94,22 @@ snow3g_set_session_parameters(struct snow3g_session *sess,
                        SNOW3G_LOG(ERR, "Wrong IV length");
                        return -EINVAL;
                }
+               if (cipher_xform->cipher.key.length > SNOW3G_MAX_KEY_SIZE) {
+                       SNOW3G_LOG(ERR, "Not enough memory to store the key");
+                       return -ENOMEM;
+               }
+
                sess->cipher_iv_offset = cipher_xform->cipher.iv.offset;
 
                /* Initialize key */
-               sso_snow3g_init_key_sched(cipher_xform->cipher.key.data,
-                               &sess->pKeySched_cipher);
+               memcpy(cipher_key, cipher_xform->cipher.key.data,
+                               cipher_xform->cipher.key.length);
+               sso_snow3g_init_key_sched(cipher_key, &sess->pKeySched_cipher);
        }
 
        if (auth_xform) {
+               uint8_t auth_key[SNOW3G_MAX_KEY_SIZE];
+
                /* Only SNOW 3G UIA2 supported */
                if (auth_xform->auth.algo != RTE_CRYPTO_AUTH_SNOW3G_UIA2)
                        return -ENOTSUP;
@@ -108,6 +118,10 @@ snow3g_set_session_parameters(struct snow3g_session *sess,
                        SNOW3G_LOG(ERR, "Wrong digest length");
                        return -EINVAL;
                }
+               if (auth_xform->auth.key.length > SNOW3G_MAX_KEY_SIZE) {
+                       SNOW3G_LOG(ERR, "Not enough memory to store the key");
+                       return -ENOMEM;
+               }
 
                sess->auth_op = auth_xform->auth.op;
 
@@ -118,8 +132,9 @@ snow3g_set_session_parameters(struct snow3g_session *sess,
                sess->auth_iv_offset = auth_xform->auth.iv.offset;
 
                /* Initialize key */
-               sso_snow3g_init_key_sched(auth_xform->auth.key.data,
-                               &sess->pKeySched_hash);
+               memcpy(auth_key, auth_xform->auth.key.data,
+                               auth_xform->auth.key.length);
+               sso_snow3g_init_key_sched(auth_key, &sess->pKeySched_hash);
        }