]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/crypto/ccp/ccp-ops.c
crypto: ccp - Fix 3DES complaint from ccp-crypto module
[mirror_ubuntu-bionic-kernel.git] / drivers / crypto / ccp / ccp-ops.c
index 1e2e42106dee070d92ac543c8e1448327caffb8a..4b48b8523a40c21515a28564dc49ecf8bc703a5a 100644 (file)
@@ -1293,6 +1293,9 @@ static int ccp_run_des3_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
        int ret;
 
        /* Error checks */
+       if (cmd_q->ccp->vdata->version < CCP_VERSION(5, 0))
+               return -EINVAL;
+
        if (!cmd_q->ccp->vdata->perform->des3)
                return -EINVAL;
 
@@ -1375,8 +1378,6 @@ static int ccp_run_des3_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
         * passthru option to convert from big endian to little endian.
         */
        if (des3->mode != CCP_DES3_MODE_ECB) {
-               u32 load_mode;
-
                op.sb_ctx = cmd_q->sb_ctx;
 
                ret = ccp_init_dm_workarea(&ctx, cmd_q,
@@ -1392,12 +1393,8 @@ static int ccp_run_des3_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
                if (ret)
                        goto e_ctx;
 
-               if (cmd_q->ccp->vdata->version == CCP_VERSION(3, 0))
-                       load_mode = CCP_PASSTHRU_BYTESWAP_NOOP;
-               else
-                       load_mode = CCP_PASSTHRU_BYTESWAP_256BIT;
                ret = ccp_copy_to_sb(cmd_q, &ctx, op.jobid, op.sb_ctx,
-                                    load_mode);
+                                    CCP_PASSTHRU_BYTESWAP_256BIT);
                if (ret) {
                        cmd->engine_error = cmd_q->cmd_error;
                        goto e_ctx;
@@ -1459,10 +1456,6 @@ static int ccp_run_des3_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
                }
 
                /* ...but we only need the last DES3_EDE_BLOCK_SIZE bytes */
-               if (cmd_q->ccp->vdata->version == CCP_VERSION(3, 0))
-                       dm_offset = CCP_SB_BYTES - des3->iv_len;
-               else
-                       dm_offset = 0;
                ccp_get_dm_area(&ctx, dm_offset, des3->iv, 0,
                                DES3_EDE_BLOCK_SIZE);
        }