cryptodev: remove AAD length from crypto op
[dpdk.git] / drivers / crypto / openssl / rte_openssl_pmd.c
index bfc2371..615763c 100644 (file)
@@ -264,6 +264,10 @@ openssl_set_session_cipher_parameters(struct openssl_session *sess,
        /* Select cipher key */
        sess->cipher.key.length = xform->cipher.key.length;
 
+       /* Set IV parameters */
+       sess->iv.offset = xform->cipher.iv.offset;
+       sess->iv.length = xform->cipher.iv.length;
+
        /* Select cipher algo */
        switch (xform->cipher.algo) {
        case RTE_CRYPTO_CIPHER_3DES_CBC:
@@ -366,6 +370,8 @@ openssl_set_session_auth_parameters(struct openssl_session *sess,
                return -EINVAL;
        }
 
+       sess->auth.aad_length = xform->auth.add_auth_data_length;
+
        return 0;
 }
 
@@ -397,6 +403,9 @@ openssl_set_session_parameters(struct openssl_session *sess,
                return -EINVAL;
        }
 
+       /* Default IV length = 0 */
+       sess->iv.length = 0;
+
        /* cipher_xform must be check before auth_xform */
        if (cipher_xform) {
                if (openssl_set_session_cipher_parameters(
@@ -923,10 +932,11 @@ process_openssl_combined_op
                return;
        }
 
-       iv = op->sym->cipher.iv.data;
-       ivlen = op->sym->cipher.iv.length;
+       iv = rte_crypto_op_ctod_offset(op, uint8_t *,
+                       sess->iv.offset);
+       ivlen = sess->iv.length;
        aad = op->sym->auth.aad.data;
-       aadlen = op->sym->auth.aad.length;
+       aadlen = sess->auth.aad_length;
 
        tag = op->sym->auth.digest.data;
        if (tag == NULL)
@@ -987,7 +997,8 @@ process_openssl_cipher_op
        dst = rte_pktmbuf_mtod_offset(mbuf_dst, uint8_t *,
                        op->sym->cipher.data.offset);
 
-       iv = op->sym->cipher.iv.data;
+       iv = rte_crypto_op_ctod_offset(op, uint8_t *,
+                       sess->iv.offset);
 
        if (sess->cipher.mode == OPENSSL_CIPHER_LIB)
                if (sess->cipher.direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
@@ -1028,7 +1039,8 @@ process_openssl_docsis_bpi_op(struct rte_crypto_op *op,
        dst = rte_pktmbuf_mtod_offset(mbuf_dst, uint8_t *,
                        op->sym->cipher.data.offset);
 
-       iv = op->sym->cipher.iv.data;
+       iv = rte_crypto_op_ctod_offset(op, uint8_t *,
+                       sess->iv.offset);
 
        block_size = DES_BLOCK_SIZE;
 
@@ -1086,7 +1098,8 @@ process_openssl_docsis_bpi_op(struct rte_crypto_op *op,
                                                dst, iv,
                                                last_block_len, sess->cipher.bpi_ctx);
                                /* Prepare parameters for CBC mode op */
-                               iv = op->sym->cipher.iv.data;
+                               iv = rte_crypto_op_ctod_offset(op, uint8_t *,
+                                               sess->iv.offset);
                                dst += last_block_len - srclen;
                                srclen -= last_block_len;
                        }