X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fcrypto%2Fsnow3g%2Frte_snow3g_pmd.c;h=9d07e1ab2c219c8579613f6ff0ab2f04e52c19e1;hb=6bc327b94fe8aaf06e7eef918d4c8c32bcaa9252;hp=5fd94b686d2a8824c37d4ed57a1b2b02de891a4f;hpb=0b60386ac353835485d2ea8add8c059cfeae9d58;p=dpdk.git diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c index 5fd94b686d..9d07e1ab2c 100644 --- a/drivers/crypto/snow3g/rte_snow3g_pmd.c +++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c @@ -10,7 +10,7 @@ #include #include -#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); }