* [PATCH v4] crypto/fsl: fsl_rsa: Fix dcache issue in the driver
@ 2022-09-28 10:19 Gaurav Jain
2022-10-21 11:42 ` sbabic
0 siblings, 1 reply; 2+ messages in thread
From: Gaurav Jain @ 2022-09-28 10:19 UTC (permalink / raw)
To: u-boot, Stefano Babic
Cc: Fabio Estevam, Peng Fan, Ye Li, NXP i . MX U-Boot Team,
Horia Geanta, Varun Sethi, Gaurav Jain
From: Ye Li <ye.li@nxp.com>
issue:
CAAM fails with key error when perform Modular Exponentiation
using PKHA Block in CAAM
Fix:
add flush and invalidate dcache for keys, signature
and output decrypted data processed by CAAM.
Fixes: 34276478f7 (DM: crypto/fsl - Add Freescale rsa DM driver)
Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Gaurav Jain <gaurav.jain@nxp.com>
Acked-by: Peng Fan <peng.fan@nxp.com>
---
changes in v4:
- upgrade to latest.
changes in v3:
- fix warning: implicit declaration of function ‘flush_dcache_range’
[-Wimplicit-function-declaration]
drivers/crypto/fsl/fsl_rsa.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/crypto/fsl/fsl_rsa.c b/drivers/crypto/fsl/fsl_rsa.c
index 897ee855ea..335b7fe25a 100644
--- a/drivers/crypto/fsl/fsl_rsa.c
+++ b/drivers/crypto/fsl/fsl_rsa.c
@@ -6,6 +6,7 @@
#include <config.h>
#include <common.h>
+#include <cpu_func.h>
#include <dm.h>
#include <log.h>
#include <asm/types.h>
@@ -36,12 +37,21 @@ int fsl_mod_exp(struct udevice *dev, const uint8_t *sig, uint32_t sig_len,
inline_cnstr_jobdesc_pkha_rsaexp(desc, &pkin, out, sig_len);
+ flush_dcache_range((ulong)sig, (ulong)sig + sig_len);
+ flush_dcache_range((ulong)prop->modulus, (ulong)(prop->modulus) + keylen);
+ flush_dcache_range((ulong)prop->public_exponent,
+ (ulong)(prop->public_exponent) + prop->exp_len);
+ flush_dcache_range((ulong)desc, (ulong)desc + (sizeof(uint32_t) * MAX_CAAM_DESCSIZE));
+ flush_dcache_range((ulong)out, (ulong)out + sig_len);
+
ret = run_descriptor_jr(desc);
if (ret) {
debug("%s: RSA failed to verify: %d\n", __func__, ret);
return -EFAULT;
}
+ invalidate_dcache_range((ulong)out, (ulong)out + sig_len);
+
return 0;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH v4] crypto/fsl: fsl_rsa: Fix dcache issue in the driver
2022-09-28 10:19 [PATCH v4] crypto/fsl: fsl_rsa: Fix dcache issue in the driver Gaurav Jain
@ 2022-10-21 11:42 ` sbabic
0 siblings, 0 replies; 2+ messages in thread
From: sbabic @ 2022-10-21 11:42 UTC (permalink / raw)
To: Gaurav Jain, u-boot
> From: Ye Li <ye.li@nxp.com>
> issue:
> CAAM fails with key error when perform Modular Exponentiation
> using PKHA Block in CAAM
> Fix:
> add flush and invalidate dcache for keys, signature
> and output decrypted data processed by CAAM.
> Fixes: 34276478f7 (DM: crypto/fsl - Add Freescale rsa DM driver)
> Signed-off-by: Ye Li <ye.li@nxp.com>
> Reviewed-by: Gaurav Jain <gaurav.jain@nxp.com>
> Acked-by: Peng Fan <peng.fan@nxp.com>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
--
=====================================================================
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: sbabic@denx.de
=====================================================================
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-21 11:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-28 10:19 [PATCH v4] crypto/fsl: fsl_rsa: Fix dcache issue in the driver Gaurav Jain
2022-10-21 11:42 ` sbabic
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox