linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: ccree: fix finup
@ 2018-06-21 11:47 Hadar Gat
  2018-06-21 12:25 ` Gilad Ben-Yossef
  0 siblings, 1 reply; 3+ messages in thread
From: Hadar Gat @ 2018-06-21 11:47 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller
  Cc: linux-crypto, linux-kernel, Ofir Drang, Gilad Ben-Yossef,
	Hadar Gat, stable

finup() operation was incorrect, padding was missing.
Fix by setting the ccree HW to enable padding.

Signed-off-by: Hadar Gat <hadar.gat@arm.com>
Cc: stable@vger.kernel.org
---
 drivers/crypto/ccree/cc_hash.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/ccree/cc_hash.c b/drivers/crypto/ccree/cc_hash.c
index 96ff777..e8bb934 100644
--- a/drivers/crypto/ccree/cc_hash.c
+++ b/drivers/crypto/ccree/cc_hash.c
@@ -500,8 +500,12 @@ static int cc_hash_digest(struct ahash_request *req)
 }
 
 static int cc_restore_hash(struct cc_hw_desc *desc, struct cc_hash_ctx *ctx,
-			   struct ahash_req_ctx *state, unsigned int idx)
+			   struct ahash_req_ctx *state, unsigned int idx,
+			   bool hash_padding)
 {
+	enum cc_hash_conf_pad pad_conf = hash_padding ? HASH_PADDING_ENABLED :
+			HASH_PADDING_DISABLED;
+
 	/* Restore hash digest */
 	hw_desc_init(&desc[idx]);
 	set_cipher_mode(&desc[idx], ctx->hw_mode);
@@ -514,7 +518,7 @@ static int cc_restore_hash(struct cc_hw_desc *desc, struct cc_hash_ctx *ctx,
 	/* Restore hash current length */
 	hw_desc_init(&desc[idx]);
 	set_cipher_mode(&desc[idx], ctx->hw_mode);
-	set_cipher_config1(&desc[idx], HASH_PADDING_DISABLED);
+	set_cipher_config1(&desc[idx], pad_conf);
 	set_din_type(&desc[idx], DMA_DLLI, state->digest_bytes_len_dma_addr,
 		     ctx->drvdata->hash_len_sz, NS_BIT);
 	set_flow_mode(&desc[idx], S_DIN_to_HASH);
@@ -572,7 +576,7 @@ static int cc_hash_update(struct ahash_request *req)
 	cc_req.user_cb = cc_update_complete;
 	cc_req.user_arg = req;
 
-	idx = cc_restore_hash(desc, ctx, state, idx);
+	idx = cc_restore_hash(desc, ctx, state, idx, false);
 
 	/* store the hash digest result in context */
 	hw_desc_init(&desc[idx]);
@@ -644,7 +648,7 @@ static int cc_hash_finup(struct ahash_request *req)
 	cc_req.user_cb = cc_hash_complete;
 	cc_req.user_arg = req;
 
-	idx = cc_restore_hash(desc, ctx, state, idx);
+	idx = cc_restore_hash(desc, ctx, state, idx, true);
 
 	if (is_hmac)
 		idx = cc_fin_hmac(desc, req, idx);
@@ -704,7 +708,7 @@ static int cc_hash_final(struct ahash_request *req)
 	cc_req.user_cb = cc_hash_complete;
 	cc_req.user_arg = req;
 
-	idx = cc_restore_hash(desc, ctx, state, idx);
+	idx = cc_restore_hash(desc, ctx, state, idx, false);
 
 	/* "DO-PAD" must be enabled only when writing current length to HW */
 	hw_desc_init(&desc[idx]);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto: ccree: fix finup
  2018-06-21 11:47 [PATCH] crypto: ccree: fix finup Hadar Gat
@ 2018-06-21 12:25 ` Gilad Ben-Yossef
  2018-06-28  7:06   ` Gilad Ben-Yossef
  0 siblings, 1 reply; 3+ messages in thread
From: Gilad Ben-Yossef @ 2018-06-21 12:25 UTC (permalink / raw)
  To: Hadar Gat
  Cc: Herbert Xu, David S. Miller, Linux Crypto Mailing List,
	Linux kernel mailing list, Ofir Drang, Gilad Ben-Yossef, stable

On Thu, Jun 21, 2018 at 2:47 PM, Hadar Gat <hadar.gat@arm.com> wrote:
> finup() operation was incorrect, padding was missing.
> Fix by setting the ccree HW to enable padding.
>
> Signed-off-by: Hadar Gat <hadar.gat@arm.com>
> Cc: stable@vger.kernel.org

Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>

Gilad


-- 
Gilad Ben-Yossef
Chief Coffee Drinker

values of β will give rise to dom!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto: ccree: fix finup
  2018-06-21 12:25 ` Gilad Ben-Yossef
@ 2018-06-28  7:06   ` Gilad Ben-Yossef
  0 siblings, 0 replies; 3+ messages in thread
From: Gilad Ben-Yossef @ 2018-06-28  7:06 UTC (permalink / raw)
  To: Hadar Gat
  Cc: Herbert Xu, David S. Miller, Linux Crypto Mailing List,
	Linux kernel mailing list, Ofir Drang, Gilad Ben-Yossef, stable

Hi Herbert,


On Thu, Jun 21, 2018 at 3:25 PM, Gilad Ben-Yossef <gilad@benyossef.com> wrote:
> On Thu, Jun 21, 2018 at 2:47 PM, Hadar Gat <hadar.gat@arm.com> wrote:
>> finup() operation was incorrect, padding was missing.
>> Fix by setting the ccree HW to enable padding.
>>
>> Signed-off-by: Hadar Gat <hadar.gat@arm.com>
>> Cc: stable@vger.kernel.org
>
> Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>
>
> Gilad
>

I took a 2nd look at this with Hadar and we realized we can write this
in a way that allows
for more code sharing. Please drop this patch. I'll be sending a revised version
in a second.

Thanks!
Gilad



-- 
Gilad Ben-Yossef
Chief Coffee Drinker

values of β will give rise to dom!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-28  7:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-21 11:47 [PATCH] crypto: ccree: fix finup Hadar Gat
2018-06-21 12:25 ` Gilad Ben-Yossef
2018-06-28  7:06   ` Gilad Ben-Yossef

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).