linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] crypto: stm32/hash: Fix bug in hmac mode
@ 2019-06-28 11:26 Lionel Debieve
  2019-06-28 11:26 ` [PATCH 1/2] crypto: stm32/hash: Fix hmac issue more than 256 bytes Lionel Debieve
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Lionel Debieve @ 2019-06-28 11:26 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, Maxime Coquelin, Alexandre Torgue,
	linux-crypto, linux-arm-kernel, linux-kernel
  Cc: Ludovic Barre, Benjamin Gaignard, Fabien Dessenne, linux-stm32

This series fixes issues discovered while using libkcapi library. Some
more tests show wrong key management in hmac mode. It is fixes by these 
patches and prevent a potential issue in case of interrupt while processing
in dma mode.

Lionel Debieve (2):
  crypto: stm32/hash: Fix hmac issue more than 256 bytes
  crypto: stm32/hash: remove interruptible condition for dma

 drivers/crypto/stm32/stm32-hash.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 1/2] crypto: stm32/hash: Fix hmac issue more than 256 bytes
  2019-06-28 11:26 [PATCH 0/2] crypto: stm32/hash: Fix bug in hmac mode Lionel Debieve
@ 2019-06-28 11:26 ` Lionel Debieve
  2019-06-28 11:26 ` [PATCH 2/2] crypto: stm32/hash: remove interruptible condition for dma Lionel Debieve
  2019-07-03 14:29 ` [PATCH 0/2] crypto: stm32/hash: Fix bug in hmac mode Herbert Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Lionel Debieve @ 2019-06-28 11:26 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, Maxime Coquelin, Alexandre Torgue,
	linux-crypto, linux-arm-kernel, linux-kernel
  Cc: Ludovic Barre, Benjamin Gaignard, Fabien Dessenne, linux-stm32

Correct condition for the second hmac loop. Key must be only
set in the first loop. Initial condition was wrong,
HMAC_KEY flag was not properly checked.

Signed-off-by: Lionel Debieve <lionel.debieve@st.com>
---
 drivers/crypto/stm32/stm32-hash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c
index 29519d1c403f..c37d1a336f98 100644
--- a/drivers/crypto/stm32/stm32-hash.c
+++ b/drivers/crypto/stm32/stm32-hash.c
@@ -349,7 +349,7 @@ static int stm32_hash_xmit_cpu(struct stm32_hash_dev *hdev,
 		return -ETIMEDOUT;
 
 	if ((hdev->flags & HASH_FLAGS_HMAC) &&
-	    (hdev->flags & ~HASH_FLAGS_HMAC_KEY)) {
+	    (!(hdev->flags & HASH_FLAGS_HMAC_KEY))) {
 		hdev->flags |= HASH_FLAGS_HMAC_KEY;
 		stm32_hash_write_key(hdev);
 		if (stm32_hash_wait_busy(hdev))
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/2] crypto: stm32/hash: remove interruptible condition for dma
  2019-06-28 11:26 [PATCH 0/2] crypto: stm32/hash: Fix bug in hmac mode Lionel Debieve
  2019-06-28 11:26 ` [PATCH 1/2] crypto: stm32/hash: Fix hmac issue more than 256 bytes Lionel Debieve
@ 2019-06-28 11:26 ` Lionel Debieve
  2019-07-03 14:29 ` [PATCH 0/2] crypto: stm32/hash: Fix bug in hmac mode Herbert Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Lionel Debieve @ 2019-06-28 11:26 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, Maxime Coquelin, Alexandre Torgue,
	linux-crypto, linux-arm-kernel, linux-kernel
  Cc: Ludovic Barre, Benjamin Gaignard, Fabien Dessenne, linux-stm32

When DMA is used, waiting for completion must not be
interruptible as it can generate an error that is not handle
by the driver. There is no need to put the completion
interruptible in this driver.

Signed-off-by: Lionel Debieve <lionel.debieve@st.com>
---
 drivers/crypto/stm32/stm32-hash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c
index c37d1a336f98..23061f2bc74b 100644
--- a/drivers/crypto/stm32/stm32-hash.c
+++ b/drivers/crypto/stm32/stm32-hash.c
@@ -447,8 +447,8 @@ static int stm32_hash_xmit_dma(struct stm32_hash_dev *hdev,
 
 	dma_async_issue_pending(hdev->dma_lch);
 
-	if (!wait_for_completion_interruptible_timeout(&hdev->dma_completion,
-						       msecs_to_jiffies(100)))
+	if (!wait_for_completion_timeout(&hdev->dma_completion,
+					 msecs_to_jiffies(100)))
 		err = -ETIMEDOUT;
 
 	if (dma_async_is_tx_complete(hdev->dma_lch, cookie,
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 0/2] crypto: stm32/hash: Fix bug in hmac mode
  2019-06-28 11:26 [PATCH 0/2] crypto: stm32/hash: Fix bug in hmac mode Lionel Debieve
  2019-06-28 11:26 ` [PATCH 1/2] crypto: stm32/hash: Fix hmac issue more than 256 bytes Lionel Debieve
  2019-06-28 11:26 ` [PATCH 2/2] crypto: stm32/hash: remove interruptible condition for dma Lionel Debieve
@ 2019-07-03 14:29 ` Herbert Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2019-07-03 14:29 UTC (permalink / raw)
  To: Lionel Debieve
  Cc: Alexandre Torgue, linux-kernel, Fabien Dessenne, linux-stm32,
	linux-crypto, Maxime Coquelin, Ludovic Barre, David S . Miller,
	linux-arm-kernel, Benjamin Gaignard

On Fri, Jun 28, 2019 at 01:26:53PM +0200, Lionel Debieve wrote:
> This series fixes issues discovered while using libkcapi library. Some
> more tests show wrong key management in hmac mode. It is fixes by these 
> patches and prevent a potential issue in case of interrupt while processing
> in dma mode.
> 
> Lionel Debieve (2):
>   crypto: stm32/hash: Fix hmac issue more than 256 bytes
>   crypto: stm32/hash: remove interruptible condition for dma
> 
>  drivers/crypto/stm32/stm32-hash.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

All applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-07-03 14:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-28 11:26 [PATCH 0/2] crypto: stm32/hash: Fix bug in hmac mode Lionel Debieve
2019-06-28 11:26 ` [PATCH 1/2] crypto: stm32/hash: Fix hmac issue more than 256 bytes Lionel Debieve
2019-06-28 11:26 ` [PATCH 2/2] crypto: stm32/hash: remove interruptible condition for dma Lionel Debieve
2019-07-03 14:29 ` [PATCH 0/2] crypto: stm32/hash: Fix bug in hmac mode Herbert Xu

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