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>
This commit is contained in:
parent
78becc7f83
commit
4668e8a45e
|
|
@ -38,6 +38,7 @@ enum hwcrypto_command {
|
||||||
|
|
||||||
HWCRYPTO_HASH = (1 << HWCRYPTO_REQ_SHIFT),
|
HWCRYPTO_HASH = (1 << HWCRYPTO_REQ_SHIFT),
|
||||||
HWCRYPTO_ENCAP_BLOB = (2 << HWCRYPTO_REQ_SHIFT),
|
HWCRYPTO_ENCAP_BLOB = (2 << HWCRYPTO_REQ_SHIFT),
|
||||||
|
HWCRYPTO_GEN_RNG = (3 << HWCRYPTO_REQ_SHIFT),
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -96,4 +97,12 @@ typedef struct hwcrypto_blob_msg {
|
||||||
uint32_t blob_pa;
|
uint32_t blob_pa;
|
||||||
}hwcrypto_blob_msg;
|
}hwcrypto_blob_msg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @buf: physical start address of the output rng buf.
|
||||||
|
* @len: size of required rng.
|
||||||
|
*/
|
||||||
|
typedef struct hwcrypto_rng_msg {
|
||||||
|
uint32_t buf;
|
||||||
|
uint32_t len;
|
||||||
|
}hwcrypto_rng_msg;
|
||||||
#endif /* TRUSTY_INTERFACE_HWCRYPTO_H_ */
|
#endif /* TRUSTY_INTERFACE_HWCRYPTO_H_ */
|
||||||
|
|
|
||||||
|
|
@ -66,4 +66,12 @@ int hwcrypto_hash(uint32_t in_addr, uint32_t in_len, uint32_t out_addr,
|
||||||
*/
|
*/
|
||||||
int hwcrypto_gen_blob(uint32_t plain_pa,
|
int hwcrypto_gen_blob(uint32_t plain_pa,
|
||||||
uint32_t plain_size, uint32_t blob_pa);
|
uint32_t plain_size, uint32_t blob_pa);
|
||||||
|
|
||||||
|
/* Send request to secure side to generate rng with caam.
|
||||||
|
* Returns one of trusty_err.
|
||||||
|
*
|
||||||
|
* @buf: physical start address of the output rng buf.
|
||||||
|
* @len: size of required rng.
|
||||||
|
* */
|
||||||
|
int hwcrypto_gen_rng(uint32_t buf, uint32_t len);
|
||||||
#endif /* TRUSTY_HWCRYPTO_H_ */
|
#endif /* TRUSTY_HWCRYPTO_H_ */
|
||||||
|
|
|
||||||
|
|
@ -218,3 +218,25 @@ int hwcrypto_gen_blob(uint32_t plain_pa,
|
||||||
sizeof(req), NULL, 0, false);
|
sizeof(req), NULL, 0, false);
|
||||||
return rc;
|
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;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue