summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJi Luo <ji.luo@nxp.com>2018-10-31 09:34:33 +0800
committerNitin Garg <nitin.garg@nxp.com>2018-11-02 20:50:09 -0500
commit4207a8df84dadbc68c99ed965661546a6af5a99c (patch)
tree17f2e6931008f428f65d845972b77481a2538190 /lib
parent86b33989f42cc97ef16dd8e57c26eb0fc96224c1 (diff)
MA-13275 [trusty] Add tipc command to generate blob with CAAM
Add new hwcrypto tipc command and handler to generate blob with CAAM. Test: Message exchange with trusty and blob encapsulate/decapsulate ok. Change-Id: I925b47cb3e22eeddf4c89e84a9c994d2f30423fe Signed-off-by: Ji Luo <ji.luo@nxp.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/trusty/ql-tipc/hwcrypto.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/trusty/ql-tipc/hwcrypto.c b/lib/trusty/ql-tipc/hwcrypto.c
index 1cefdc46fa..69914a9762 100644
--- a/lib/trusty/ql-tipc/hwcrypto.c
+++ b/lib/trusty/ql-tipc/hwcrypto.c
@@ -30,6 +30,7 @@
#include "common.h"
#define LOCAL_LOG 0
+#define CAAM_KB_HEADER_LEN 48
static bool initialized;
static struct trusty_ipc_chan hwcrypto_chan;
@@ -187,3 +188,33 @@ int hwcrypto_hash(uint32_t in_addr, uint32_t in_len, uint32_t out_addr,
sizeof(req), NULL, 0, false);
return rc;
}
+
+int hwcrypto_gen_blob(uint32_t plain_pa,
+ uint32_t plain_size, uint32_t blob_pa)
+{
+ hwcrypto_blob_msg req;
+ unsigned long start, end;
+
+ /* check the address */
+ if (plain_pa == 0 || blob_pa == 0)
+ return TRUSTY_ERR_INVALID_ARGS;
+ /* fill the request buffer */
+ req.plain_pa = plain_pa;
+ req.plain_size = plain_size;
+ req.blob_pa = blob_pa;
+
+ /* flush dcache for input buffer */
+ start = (unsigned long)plain_pa & ~(ARCH_DMA_MINALIGN - 1);
+ end = ALIGN((unsigned long)plain_pa + plain_size, ARCH_DMA_MINALIGN);
+ flush_dcache_range(start, end);
+
+ /* invalidate dcache for output buffer */
+ start = (unsigned long)blob_pa & ~(ARCH_DMA_MINALIGN - 1);
+ end = ALIGN((unsigned long)blob_pa + plain_size +
+ CAAM_KB_HEADER_LEN, ARCH_DMA_MINALIGN);
+ invalidate_dcache_range(start, end);
+
+ int rc = hwcrypto_do_tipc(HWCRYPTO_ENCAP_BLOB, (void*)&req,
+ sizeof(req), NULL, 0, false);
+ return rc;
+}