Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: ccp - Fix handling of RSA exponent on a v5 device

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>

authored by

Gary R Hook and committed by
Herbert Xu
e6414b13 89277a7d

+5 -5
+5 -5
drivers/crypto/ccp/ccp-dev-v5.c
··· 403 403 CCP5_CMD_PROT(&desc) = 0; 404 404 405 405 function.raw = 0; 406 - CCP_RSA_SIZE(&function) = op->u.rsa.mod_size; 406 + CCP_RSA_SIZE(&function) = op->u.rsa.mod_size >> 3; 407 407 CCP5_CMD_FUNCTION(&desc) = function.raw; 408 408 409 409 CCP5_CMD_LEN(&desc) = op->u.rsa.input_len; ··· 418 418 CCP5_CMD_DST_HI(&desc) = ccp_addr_hi(&op->dst.u.dma); 419 419 CCP5_CMD_DST_MEM(&desc) = CCP_MEMTYPE_SYSTEM; 420 420 421 - /* Key (Exponent) is in external memory */ 422 - CCP5_CMD_KEY_LO(&desc) = ccp_addr_lo(&op->exp.u.dma); 423 - CCP5_CMD_KEY_HI(&desc) = ccp_addr_hi(&op->exp.u.dma); 424 - CCP5_CMD_KEY_MEM(&desc) = CCP_MEMTYPE_SYSTEM; 421 + /* Exponent is in LSB memory */ 422 + CCP5_CMD_KEY_LO(&desc) = op->sb_key * LSB_ITEM_SIZE; 423 + CCP5_CMD_KEY_HI(&desc) = 0; 424 + CCP5_CMD_KEY_MEM(&desc) = CCP_MEMTYPE_SB; 425 425 426 426 return ccp5_do_cmd(&desc, op->cmd_q); 427 427 }