crypto/armv8: do not append digest
[dpdk.git] / drivers / crypto / armv8 / rte_armv8_pmd.c
index c3ba439..dbe6bee 100644 (file)
@@ -291,27 +291,14 @@ auth_set_prerequisites(struct armv8_crypto_session *sess,
                 * Generate authentication key, i_key_pad and o_key_pad.
                 */
                /* Zero memory under key */
-               memset(sess->auth.hmac.key, 0, SHA1_AUTH_KEY_LENGTH);
-
-               if (xform->auth.key.length > SHA1_AUTH_KEY_LENGTH) {
-                       /*
-                        * In case the key is longer than 160 bits
-                        * the algorithm will use SHA1(key) instead.
-                        */
-                       error = sha1_block(NULL, xform->auth.key.data,
-                               sess->auth.hmac.key, xform->auth.key.length);
-                       if (error != 0)
-                               return -1;
-               } else {
-                       /*
-                        * Now copy the given authentication key to the session
-                        * key assuming that the session key is zeroed there is
-                        * no need for additional zero padding if the key is
-                        * shorter than SHA1_AUTH_KEY_LENGTH.
-                        */
-                       rte_memcpy(sess->auth.hmac.key, xform->auth.key.data,
-                                                       xform->auth.key.length);
-               }
+               memset(sess->auth.hmac.key, 0, SHA1_BLOCK_SIZE);
+
+               /*
+                * Now copy the given authentication key to the session
+                * key.
+                */
+               rte_memcpy(sess->auth.hmac.key, xform->auth.key.data,
+                                               xform->auth.key.length);
 
                /* Prepare HMAC padding: key|pattern */
                auth_hmac_pad_prepare(sess, xform);
@@ -337,27 +324,14 @@ auth_set_prerequisites(struct armv8_crypto_session *sess,
                 * Generate authentication key, i_key_pad and o_key_pad.
                 */
                /* Zero memory under key */
-               memset(sess->auth.hmac.key, 0, SHA256_AUTH_KEY_LENGTH);
-
-               if (xform->auth.key.length > SHA256_AUTH_KEY_LENGTH) {
-                       /*
-                        * In case the key is longer than 256 bits
-                        * the algorithm will use SHA256(key) instead.
-                        */
-                       error = sha256_block(NULL, xform->auth.key.data,
-                               sess->auth.hmac.key, xform->auth.key.length);
-                       if (error != 0)
-                               return -1;
-               } else {
-                       /*
-                        * Now copy the given authentication key to the session
-                        * key assuming that the session key is zeroed there is
-                        * no need for additional zero padding if the key is
-                        * shorter than SHA256_AUTH_KEY_LENGTH.
-                        */
-                       rte_memcpy(sess->auth.hmac.key, xform->auth.key.data,
-                                                       xform->auth.key.length);
-               }
+               memset(sess->auth.hmac.key, 0, SHA256_BLOCK_SIZE);
+
+               /*
+                * Now copy the given authentication key to the session
+                * key.
+                */
+               rte_memcpy(sess->auth.hmac.key, xform->auth.key.data,
+                                               xform->auth.key.length);
 
                /* Prepare HMAC padding: key|pattern */
                auth_hmac_pad_prepare(sess, xform);
@@ -601,8 +575,8 @@ get_session(struct armv8_crypto_qp *qp, struct rte_crypto_op *op)
 
 /** Process cipher operation */
 static inline void
-process_armv8_chained_op
-               (struct rte_crypto_op *op, struct armv8_crypto_session *sess,
+process_armv8_chained_op(struct armv8_crypto_qp *qp, struct rte_crypto_op *op,
+               struct armv8_crypto_session *sess,
                struct rte_mbuf *mbuf_src, struct rte_mbuf *mbuf_dst)
 {
        crypto_func_t crypto_func;
@@ -659,8 +633,7 @@ process_armv8_chained_op
                                        op->sym->auth.data.length);
                }
        } else {
-               adst = (uint8_t *)rte_pktmbuf_append(m_asrc,
-                               sess->auth.digest_length);
+               adst = qp->temp_digest;
        }
 
        arg.cipher.iv = rte_crypto_op_ctod_offset(op, uint8_t *,
@@ -681,15 +654,12 @@ process_armv8_chained_op
                                sess->auth.digest_length) != 0) {
                        op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
                }
-               /* Trim area used for digest from mbuf. */
-               rte_pktmbuf_trim(m_asrc,
-                               sess->auth.digest_length);
        }
 }
 
 /** Process crypto operation for mbuf */
 static inline int
-process_op(const struct armv8_crypto_qp *qp, struct rte_crypto_op *op,
+process_op(struct armv8_crypto_qp *qp, struct rte_crypto_op *op,
                struct armv8_crypto_session *sess)
 {
        struct rte_mbuf *msrc, *mdst;
@@ -702,7 +672,7 @@ process_op(const struct armv8_crypto_qp *qp, struct rte_crypto_op *op,
        switch (sess->chain_order) {
        case ARMV8_CRYPTO_CHAIN_CIPHER_AUTH:
        case ARMV8_CRYPTO_CHAIN_AUTH_CIPHER: /* Fall through */
-               process_armv8_chained_op(op, sess, msrc, mdst);
+               process_armv8_chained_op(qp, op, sess, msrc, mdst);
                break;
        default:
                op->status = RTE_CRYPTO_OP_STATUS_ERROR;
@@ -908,15 +878,18 @@ cryptodev_armv8_crypto_uninit(struct rte_vdev_device *vdev)
        return 0;
 }
 
-static struct rte_vdev_driver armv8_crypto_drv = {
+static struct rte_vdev_driver armv8_crypto_pmd_drv = {
        .probe = cryptodev_armv8_crypto_init,
        .remove = cryptodev_armv8_crypto_uninit
 };
 
-RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_ARMV8_PMD, armv8_crypto_drv);
+static struct cryptodev_driver armv8_crypto_drv;
+
+RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_ARMV8_PMD, armv8_crypto_pmd_drv);
 RTE_PMD_REGISTER_ALIAS(CRYPTODEV_NAME_ARMV8_PMD, cryptodev_armv8_pmd);
 RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_ARMV8_PMD,
        "max_nb_queue_pairs=<int> "
        "max_nb_sessions=<int> "
        "socket_id=<int>");
-RTE_PMD_REGISTER_CRYPTO_DRIVER(armv8_crypto_drv, cryptodev_driver_id);
+RTE_PMD_REGISTER_CRYPTO_DRIVER(armv8_crypto_drv, armv8_crypto_pmd_drv,
+               cryptodev_driver_id);