Skip to contentSkip to conversation

crypto: stm32/hash: Fix bug in hmac mode

PATCH In review Lionel Debieve 2 participants 4 messages Jun 28, 2019 – Jul 3, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover crypto: stm32/hash: Fix bug in hmac mode

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(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 crypto: stm32/hash: Fix hmac issue more than 256 bytes

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.

---
 drivers/crypto/stm32/stm32-hash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/stm32/stm32-hash.c +1 -1
index 29519d1c403f..c37d1a336f98 100644
@@ -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))
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/2 crypto: stm32/hash: remove interruptible condition for dma

In reply to Lionel Debieve

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.

---
 drivers/crypto/stm32/stm32-hash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/stm32/stm32-hash.c +2 -2
index c37d1a336f98..23061f2bc74b 100644
@@ -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,
Signature · 1 line
2.17.1
maintainer
#3 lore raw
In reply to Lionel Debieve
Quoted 11 lines · Lionel Debieve

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.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt