X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fcrypto%2Fsnow3g%2Frte_snow3g_pmd.c;h=b21691f409a12be022b150b4557a883e7c7fc7af;hb=0fbd75a99f;hp=68121b0e0d75b18cb2c12433097c4f158dc2c8b3;hpb=5082f991f6def0ef06e9ff1cf9f39ef3b78657c5;p=dpdk.git diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd.c b/drivers/crypto/snow3g/rte_snow3g_pmd.c index 68121b0e0d..b21691f409 100644 --- a/drivers/crypto/snow3g/rte_snow3g_pmd.c +++ b/drivers/crypto/snow3g/rte_snow3g_pmd.c @@ -116,6 +116,13 @@ snow3g_set_session_parameters(struct snow3g_session *sess, /* Only SNOW 3G UEA2 supported */ if (cipher_xform->cipher.algo != RTE_CRYPTO_CIPHER_SNOW3G_UEA2) return -EINVAL; + + if (cipher_xform->cipher.iv.length != SNOW3G_IV_LENGTH) { + SNOW3G_LOG_ERR("Wrong IV length"); + return -EINVAL; + } + sess->iv_offset = cipher_xform->cipher.iv.offset; + /* Initialize key */ sso_snow3g_init_key_sched(cipher_xform->cipher.key.data, &sess->pKeySched_cipher); @@ -178,13 +185,6 @@ process_snow3g_cipher_op(struct rte_crypto_op **ops, uint32_t num_bytes[SNOW3G_MAX_BURST]; for (i = 0; i < num_ops; i++) { - /* Sanity checks. */ - if (unlikely(ops[i]->sym->cipher.iv.length != SNOW3G_IV_LENGTH)) { - ops[i]->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS; - SNOW3G_LOG_ERR("iv"); - break; - } - src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) + (ops[i]->sym->cipher.data.offset >> 3); dst[i] = ops[i]->sym->m_dst ? @@ -193,7 +193,7 @@ process_snow3g_cipher_op(struct rte_crypto_op **ops, rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *) + (ops[i]->sym->cipher.data.offset >> 3); iv[i] = rte_crypto_op_ctod_offset(ops[i], uint8_t *, - ops[i]->sym->cipher.iv.offset); + session->iv_offset); num_bytes[i] = ops[i]->sym->cipher.data.length >> 3; processed_ops++; @@ -214,13 +214,6 @@ process_snow3g_cipher_op_bit(struct rte_crypto_op *op, uint8_t *iv; uint32_t length_in_bits, offset_in_bits; - /* Sanity checks. */ - if (unlikely(op->sym->cipher.iv.length != SNOW3G_IV_LENGTH)) { - op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS; - SNOW3G_LOG_ERR("iv"); - return 0; - } - offset_in_bits = op->sym->cipher.data.offset; src = rte_pktmbuf_mtod(op->sym->m_src, uint8_t *); if (op->sym->m_dst == NULL) { @@ -230,7 +223,7 @@ process_snow3g_cipher_op_bit(struct rte_crypto_op *op, } dst = rte_pktmbuf_mtod(op->sym->m_dst, uint8_t *); iv = rte_crypto_op_ctod_offset(op, uint8_t *, - op->sym->cipher.iv.offset); + session->iv_offset); length_in_bits = op->sym->cipher.data.length; sso_snow3g_f8_1_buffer_bit(&session->pKeySched_cipher, iv,