imx: ele_api: add DEK Blob generation

- Add crc computation.
- Add ele_generate_dek_blob API for encrypted boot support.

Signed-off-by: Clement Faure <clement.faure@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
This commit is contained in:
Peng Fan
2023-07-13 11:29:40 +02:00
committed by Stefano Babic
parent 31e5ec2323
commit d0e2a012a3
2 changed files with 45 additions and 1 deletions
+1 -1
View File
@@ -142,11 +142,11 @@ int ele_read_common_fuse(u16 fuse_id, u32 *fuse_words, u32 fuse_num, u32 *respon
int ele_release_caam(u32 core_did, u32 *response);
int ele_get_fw_version(u32 *fw_version, u32 *sha1, u32 *response);
int ele_get_events(u32 *events, u32 *events_cnt, u32 *response);
int ele_generate_dek_blob(u32 key_id, u32 src_paddr, u32 dst_paddr, u32 max_output_size);
int ele_dump_buffer(u32 *buffer, u32 buffer_length);
int ele_get_info(struct ele_get_info_data *info, u32 *response);
int ele_get_fw_status(u32 *status, u32 *response);
int ele_release_m33_trout(void);
int ele_write_secure_fuse(ulong signed_msg_blk, u32 *response);
int ele_return_lifecycle_update(ulong signed_msg_blk, u32 *response);
#endif
+44
View File
@@ -14,6 +14,18 @@
DECLARE_GLOBAL_DATA_PTR;
static u32 compute_crc(const struct ele_msg *msg)
{
u32 crc = 0;
size_t i = 0;
u32 *data = (u32 *)msg;
for (i = 0; i < (msg->size - 1); i++)
crc ^= data[i];
return crc;
}
int ele_release_rdc(u8 core_id, u8 xrdc, u32 *response)
{
struct udevice *dev = gd->arch.ele_dev;
@@ -552,3 +564,35 @@ int ele_return_lifecycle_update(ulong signed_msg_blk, u32 *response)
return ret;
}
int ele_generate_dek_blob(u32 key_id, u32 src_paddr, u32 dst_paddr, u32 max_output_size)
{
struct udevice *dev = gd->arch.ele_dev;
int size = sizeof(struct ele_msg);
struct ele_msg msg;
int ret;
if (!dev) {
printf("ele dev is not initialized\n");
return -ENODEV;
}
msg.version = ELE_VERSION;
msg.tag = ELE_CMD_TAG;
msg.size = 8;
msg.command = ELE_GENERATE_DEK_BLOB;
msg.data[0] = key_id;
msg.data[1] = 0x0;
msg.data[2] = src_paddr;
msg.data[3] = 0x0;
msg.data[4] = dst_paddr;
msg.data[5] = max_output_size;
msg.data[6] = compute_crc(&msg);
ret = misc_call(dev, false, &msg, size, &msg, size);
if (ret)
printf("Error: %s: ret 0x%x, response 0x%x\n",
__func__, ret, msg.data[0]);
return ret;
}