linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gary R Hook <gary.hook@amd.com>
To: <linux-crypto@vger.kernel.org>
Cc: <thomas.lendacky@amd.com>, <herbert@gondor.apana.org.au>,
	<davem@davemloft.net>
Subject: [PATCH V2 1/9] crypto: ccp - Fix handling of RSA exponent on a v5 device
Date: Fri, 4 Nov 2016 11:03:34 -0500	[thread overview]
Message-ID: <20161104160334.18155.32509.stgit@taos> (raw)
In-Reply-To: <20161104160140.18155.75618.stgit@taos>

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>
---
 drivers/crypto/ccp/ccp-dev-v5.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c
index ff7816a..e2ce819 100644
--- a/drivers/crypto/ccp/ccp-dev-v5.c
+++ b/drivers/crypto/ccp/ccp-dev-v5.c
@@ -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);
 }

  reply	other threads:[~2016-11-04 16:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-04 16:03 [PATCH V2 0/9] Enable hashing and ciphers for v5 CCP Gary R Hook
2016-11-04 16:03 ` Gary R Hook [this message]
2016-11-04 16:03 ` [PATCH V2 2/9] crypto: ccp - Update the command queue on errors Gary R Hook
2016-11-04 16:03 ` [PATCH V2 3/9] crypto: ccp - Simplify some buffer management routines Gary R Hook
2016-11-04 16:04 ` [PATCH V2 4/9] crypto: ccp - Add SHA-2 support Gary R Hook
2016-11-04 16:04 ` [PATCH V2 5/9] crypto: Move RSA+MPI constructs into an #include file Gary R Hook
2016-11-04 16:04 ` [PATCH V2 6/9] crypto: ccp - Add support for RSA on the CCP Gary R Hook
2016-11-13  9:39   ` Herbert Xu
2016-11-15 21:42     ` Gary R Hook
2016-11-04 16:04 ` [PATCH V2 7/9] crypto: ccp - Enhance RSA support for a v5 CCP Gary R Hook
2016-11-04 16:04 ` [PATCH V2 8/9] crypto: ccp - Enable support for AES GCM on v5 CCPs Gary R Hook
2016-11-04 16:05 ` [PATCH V2 9/9] crypto: ccp - Enable 3DES function " Gary R Hook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161104160334.18155.32509.stgit@taos \
    --to=gary.hook@amd.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=thomas.lendacky@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).