drivers/crypto: fix different auth/cipher keys
authorPablo de Lara <pablo.de.lara.guarch@intel.com>
Tue, 7 Feb 2017 22:49:58 +0000 (22:49 +0000)
committerPablo de Lara <pablo.de.lara.guarch@intel.com>
Fri, 10 Feb 2017 15:03:46 +0000 (16:03 +0100)
When ciphering and authenticating in the same operation
(cipher-then-auth or auth-then-cipher),
the cipher key and authentication key were set with the same
key, in SNOW3G, KASUMI and ZUC PMDs.
They were using the key of the first transform structure,
instead of using the keys of the two different transform
structures.

This is not a big issue, since usually, the same key is
used for ciphering and authentication, but keys may be different.

Fixes: 3aafc423cf4d ("snow3g: add driver for SNOW 3G library")
Fixes: 2773c86d061a ("crypto/kasumi: add driver for KASUMI library")
Fixes: cf7685d68f00 ("crypto/zuc: add driver for ZUC library")
Cc: stable@dpdk.org
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Deepak Kumar Jain <deepak.k.jain@intel.com>
drivers/crypto/kasumi/rte_kasumi_pmd.c
drivers/crypto/snow3g/rte_snow3g_pmd.c
drivers/crypto/zuc/rte_zuc_pmd.c

index a1ec6537306541e153b0d94ddccacf334246efe8..234921e0ef1f5578b2a44b09e8337db5667d1c4b 100644 (file)
@@ -116,7 +116,7 @@ kasumi_set_session_parameters(struct kasumi_session *sess,
                if (cipher_xform->cipher.algo != RTE_CRYPTO_CIPHER_KASUMI_F8)
                        return -EINVAL;
                /* Initialize key */
-               sso_kasumi_init_f8_key_sched(xform->cipher.key.data,
+               sso_kasumi_init_f8_key_sched(cipher_xform->cipher.key.data,
                                &sess->pKeySched_cipher);
        }
 
@@ -126,7 +126,7 @@ kasumi_set_session_parameters(struct kasumi_session *sess,
                        return -EINVAL;
                sess->auth_op = auth_xform->auth.op;
                /* Initialize key */
-               sso_kasumi_init_f9_key_sched(xform->auth.key.data,
+               sso_kasumi_init_f9_key_sched(auth_xform->auth.key.data,
                                &sess->pKeySched_hash);
        }
 
index bccf6a5785e3bb602d106b3721fb05266d1b6a48..ca97271b86609e6de1b7349e4c31a6fbf336d7f1 100644 (file)
@@ -116,7 +116,7 @@ snow3g_set_session_parameters(struct snow3g_session *sess,
                if (cipher_xform->cipher.algo != RTE_CRYPTO_CIPHER_SNOW3G_UEA2)
                        return -EINVAL;
                /* Initialize key */
-               sso_snow3g_init_key_sched(xform->cipher.key.data,
+               sso_snow3g_init_key_sched(cipher_xform->cipher.key.data,
                                &sess->pKeySched_cipher);
        }
 
@@ -126,7 +126,7 @@ snow3g_set_session_parameters(struct snow3g_session *sess,
                        return -EINVAL;
                sess->auth_op = auth_xform->auth.op;
                /* Initialize key */
-               sso_snow3g_init_key_sched(xform->auth.key.data,
+               sso_snow3g_init_key_sched(auth_xform->auth.key.data,
                                &sess->pKeySched_hash);
        }
 
index fabcfb4d79f514add655dd5f7154c0caf83aae4f..6f9c06a0bcee5efa78b7ca4fc3b8882b9717ac07 100644 (file)
@@ -115,7 +115,8 @@ zuc_set_session_parameters(struct zuc_session *sess,
                if (cipher_xform->cipher.algo != RTE_CRYPTO_CIPHER_ZUC_EEA3)
                        return -EINVAL;
                /* Copy the key */
-               memcpy(sess->pKey_cipher, xform->cipher.key.data, ZUC_IV_KEY_LENGTH);
+               memcpy(sess->pKey_cipher, cipher_xform->cipher.key.data,
+                               ZUC_IV_KEY_LENGTH);
        }
 
        if (auth_xform) {
@@ -124,7 +125,8 @@ zuc_set_session_parameters(struct zuc_session *sess,
                        return -EINVAL;
                sess->auth_op = auth_xform->auth.op;
                /* Copy the key */
-               memcpy(sess->pKey_hash, xform->auth.key.data, ZUC_IV_KEY_LENGTH);
+               memcpy(sess->pKey_hash, auth_xform->auth.key.data,
+                               ZUC_IV_KEY_LENGTH);
        }