summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJi Luo <ji.luo@nxp.com>2018-12-20 15:33:26 +0800
committerJi Luo <ji.luo@nxp.com>2018-12-24 09:13:37 +0800
commit4668e8a45e6226801bb8da0571af626d81e981fb (patch)
tree7c47637c8d1131414ba6650b3dd36c67403aca2f /lib
parent78becc7f837b49e87accb60d7e9a0ba75a353b3e (diff)
MA-13831-3 [trusty] Add command to generate rng with CAAM
Add new hwcrypto command to support rng generation with CAAM. Test: rng generated on imx8qxp_mek. Change-Id: I756f3e99423f0f9dfc2bcd30117a3f96e9f5f2f7 Signed-off-by: Ji Luo <ji.luo@nxp.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/trusty/ql-tipc/hwcrypto.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/trusty/ql-tipc/hwcrypto.c b/lib/trusty/ql-tipc/hwcrypto.c
index 02b7b198eb..ccaf18b427 100644
--- a/lib/trusty/ql-tipc/hwcrypto.c
+++ b/lib/trusty/ql-tipc/hwcrypto.c
@@ -218,3 +218,25 @@ int hwcrypto_gen_blob(uint32_t plain_pa,
sizeof(req), NULL, 0, false);
return rc;
}
+
+int hwcrypto_gen_rng(uint32_t buf, uint32_t len)
+{
+ hwcrypto_rng_msg req;
+ unsigned long start, end;
+
+ /* check the address */
+ if (buf == 0)
+ return TRUSTY_ERR_INVALID_ARGS;
+ /* fill the request buffer */
+ req.buf = buf;
+ req.len = len;
+
+ /* invalidate dcache for output buffer */
+ start = (unsigned long)buf & ~(ARCH_DMA_MINALIGN - 1);
+ end = ALIGN((unsigned long)buf + len, ARCH_DMA_MINALIGN);
+ invalidate_dcache_range(start, end);
+
+ int rc = hwcrypto_do_tipc(HWCRYPTO_GEN_RNG, (void*)&req,
+ sizeof(req), NULL, 0, false);
+ return rc;
+}