Skip to contentSkip to conversation

crypto/fsl: Clear the memory when blob decapsulation fails

PATCH In review Gaurav Jain 3 participants 3 messages Apr 15, 2022 – Apr 22, 2022 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto/fsl: Clear the memory when blob decapsulation fails

issue: blob decapsulation operation store the decrypted data
in memory even if ICV check failed.

fix: clear the blob data output memory.

Fixes c5de15cbc8 (crypto/fsl: Add command for encapsulating/decapsulating blobs)
---
 drivers/crypto/fsl/fsl_blob.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/crypto/fsl/fsl_blob.c +4 -0
index e8202cc569..9b6e4bca06 100644
@@ -71,6 +71,10 @@ int blob_decap(u8 *key_mod, u8 *src, u8 *dst, u32 len)
 	ret = run_descriptor_jr(desc);
 
 	if (ret) {
+		/* clear the blob data output buffer */
+		memset(dst, 0x00, len);
+		size = ALIGN(len, ARCH_DMA_MINALIGN);
+		flush_dcache_range((unsigned long)dst, (unsigned long)dst + size);
 		printf("Error in blob decapsulation: %d\n", ret);
 	} else {
 		size = ALIGN(len, ARCH_DMA_MINALIGN);
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Gaurav Jain

issue: blob decapsulation operation store the decrypted data
in memory even if ICV check failed.

fix: clear the blob data output memory.

Fixes c5de15cbc8 (crypto/fsl: Add command for encapsulating/decapsulating blobs)
#2 lore raw

PATCH 1/1 crypto/fsl: Clear the memory when blob decapsulation fails

In reply to Gaurav Jain
Quoted 8 lines

issue: blob decapsulation operation store the decrypted data
in memory even if ICV check failed.
fix: clear the blob data output memory.

Fixes c5de15cbc8 (crypto/fsl: Add command for encapsulating/decapsulating blobs)

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================