]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
crypto: ccp - Set the AES size field for all modes
authorGary R Hook <gary.hook@amd.com>
Wed, 8 Feb 2017 19:07:06 +0000 (13:07 -0600)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 15 Feb 2017 05:20:19 +0000 (13:20 +0800)
Ensure that the size field is correctly populated for
all AES modes.

Signed-off-by: Gary R Hook <gary.hook@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/ccp/ccp-dev-v5.c
drivers/crypto/ccp/ccp-dev.h
drivers/crypto/ccp/ccp-ops.c

index 612898b4aaad045f7e96429ac325ecbec91a4295..9c6ff8b813d966e86f3aa0e56116fcdb6ecee203 100644 (file)
@@ -284,8 +284,7 @@ static int ccp5_perform_aes(struct ccp_op *op)
        CCP_AES_ENCRYPT(&function) = op->u.aes.action;
        CCP_AES_MODE(&function) = op->u.aes.mode;
        CCP_AES_TYPE(&function) = op->u.aes.type;
-       if (op->u.aes.mode == CCP_AES_MODE_CFB)
-               CCP_AES_SIZE(&function) = 0x7f;
+       CCP_AES_SIZE(&function) = op->u.aes.size;
 
        CCP5_CMD_FUNCTION(&desc) = function.raw;
 
index 649e5610a5cea7d08a95767af1c8f8e0153e0b7a..2b5c01fade05a526d5e78241eab38ec16e790aa6 100644 (file)
@@ -467,6 +467,7 @@ struct ccp_aes_op {
        enum ccp_aes_type type;
        enum ccp_aes_mode mode;
        enum ccp_aes_action action;
+       unsigned int size;
 };
 
 struct ccp_xts_aes_op {
index 50fae4442801ca76f0411d7023c915895661fe5a..6878160234b5d0b4d6a78ed282878c71aa30625a 100644 (file)
@@ -692,6 +692,14 @@ static int ccp_run_aes_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
                        goto e_ctx;
                }
        }
+       switch (aes->mode) {
+       case CCP_AES_MODE_CFB: /* CFB128 only */
+       case CCP_AES_MODE_CTR:
+               op.u.aes.size = AES_BLOCK_SIZE * BITS_PER_BYTE - 1;
+               break;
+       default:
+               op.u.aes.size = 0;
+       }
 
        /* Prepare the input and output data workareas. For in-place
         * operations we need to set the dma direction to BIDIRECTIONAL