]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
crypto: ccp - Fix handling of RSA exponent on a v5 device
authorGary R Hook <gary.hook@amd.com>
Tue, 1 Nov 2016 19:05:05 +0000 (14:05 -0500)
committerSomasundaram Krishnasamy <somasundaram.krishnasamy@oracle.com>
Thu, 24 Aug 2017 17:56:02 +0000 (10:56 -0700)
Orabug: 26644685

The exponent size in the ccp_op structure is in bits. A v5
CCP requires the exponent size to be in bytes, so convert
the size from bits to bytes when populating the descriptor.

The current code references the exponent in memory, but
these fields have not been set since the exponent is
actually store in the LSB. Populate the descriptor with
the LSB location (address).

Signed-off-by: Gary R Hook <gary.hook@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit e6414b13ea39e3011901a84eb1bdefa65610b0f8)
Signed-off-by: Somasundaram Krishnasamy <somasundaram.krishnasamy@oracle.com>
Reviewed-by: Jack Vogel <jack.vogel@oracle.com>
drivers/crypto/ccp/ccp-dev-v5.c

index ff7816a2b8afa0a2a6321eebaf185650dcc2ce36..e2ce8190ecc9a5c0baf3f6e642a4cff17f89862c 100644 (file)
@@ -403,7 +403,7 @@ static int ccp5_perform_rsa(struct ccp_op *op)
        CCP5_CMD_PROT(&desc) = 0;
 
        function.raw = 0;
-       CCP_RSA_SIZE(&function) = op->u.rsa.mod_size;
+       CCP_RSA_SIZE(&function) = op->u.rsa.mod_size >> 3;
        CCP5_CMD_FUNCTION(&desc) = function.raw;
 
        CCP5_CMD_LEN(&desc) = op->u.rsa.input_len;
@@ -418,10 +418,10 @@ static int ccp5_perform_rsa(struct ccp_op *op)
        CCP5_CMD_DST_HI(&desc) = ccp_addr_hi(&op->dst.u.dma);
        CCP5_CMD_DST_MEM(&desc) = CCP_MEMTYPE_SYSTEM;
 
-       /* Key (Exponent) is in external memory */
-       CCP5_CMD_KEY_LO(&desc) = ccp_addr_lo(&op->exp.u.dma);
-       CCP5_CMD_KEY_HI(&desc) = ccp_addr_hi(&op->exp.u.dma);
-       CCP5_CMD_KEY_MEM(&desc) = CCP_MEMTYPE_SYSTEM;
+       /* Exponent is in LSB memory */
+       CCP5_CMD_KEY_LO(&desc) = op->sb_key * LSB_ITEM_SIZE;
+       CCP5_CMD_KEY_HI(&desc) = 0;
+       CCP5_CMD_KEY_MEM(&desc) = CCP_MEMTYPE_SB;
 
        return ccp5_do_cmd(&desc, op->cmd_q);
 }