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>
This commit is contained in:
parent
86b33989f4
commit
4207a8df84
|
|
@ -37,6 +37,7 @@ enum hwcrypto_command {
|
|||
HWCRYPTO_RESP_BIT = 1,
|
||||
|
||||
HWCRYPTO_HASH = (1 << HWCRYPTO_REQ_SHIFT),
|
||||
HWCRYPTO_ENCAP_BLOB = (2 << HWCRYPTO_REQ_SHIFT),
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -84,4 +85,15 @@ typedef struct hwcrypto_hash_msg {
|
|||
enum hwcrypto_hash_algo algo;
|
||||
} hwcrypto_hash_msg;
|
||||
|
||||
/**
|
||||
* @plain_pa: physical start address of the plain blob buf.
|
||||
* @plain_size: size of the plain blob.
|
||||
* @blob: physical start addrss of the output buf.
|
||||
*/
|
||||
typedef struct hwcrypto_blob_msg {
|
||||
uint32_t plain_pa;
|
||||
uint32_t plain_size;
|
||||
uint32_t blob_pa;
|
||||
}hwcrypto_blob_msg;
|
||||
|
||||
#endif /* TRUSTY_INTERFACE_HWCRYPTO_H_ */
|
||||
|
|
|
|||
|
|
@ -56,4 +56,14 @@ void hwcrypto_tipc_shutdown(struct trusty_ipc_dev *dev);
|
|||
int hwcrypto_hash(uint32_t in_addr, uint32_t in_len, uint32_t out_addr,
|
||||
uint32_t out_len, enum hwcrypto_hash_algo algo);
|
||||
|
||||
/*
|
||||
* Send request to secure side to generate blob with caam.
|
||||
* Returns one of trusty_err.
|
||||
*
|
||||
* @plain_pa: physical start address of the plain blob buffer.
|
||||
* @plain_size: size of the plain blob buffer.
|
||||
* @blob_pa: physical start address of the generated blob buffer.
|
||||
*/
|
||||
int hwcrypto_gen_blob(uint32_t plain_pa,
|
||||
uint32_t plain_size, uint32_t blob_pa);
|
||||
#endif /* TRUSTY_HWCRYPTO_H_ */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue