Skip to content

Commit

Permalink
qseecom: configurable encryption key size
Browse files Browse the repository at this point in the history
ICE crypto engine key size can now be configured using dtsi flag.
This was required to facilitate usage of common TZ image with variable
key sizes and also provides flexibility in handling different key sizes
requirment in future. dtsi flag is parsed in driver and depending upon
the value corresponding key size is passed to TZ.

Change-Id: If40f83a943e5ae8333d171c21823a16816d7ddd4
Signed-off-by: Neeraj Soni <neersoni@codeaurora.org>
  • Loading branch information
Neeraj Soni authored and bgcngm committed Jan 6, 2017
1 parent e037725 commit 927b944
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Documentation/devicetree/bindings/qseecom/qseecom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Optional properties:
- vdd-hba-supply : handle for fixed power regulator
- qcom,qsee-reentrancy-support: indicates the qsee reentrancy phase supported by the target
- qcom,commonlib64-loaded-by-uefi: indicates commonlib64 is loaded by uefi already
- qcom,fde-key-size: indicates which FDE key size is used in device.

Example:
qcom,qseecom@fe806000 {
Expand All @@ -46,6 +47,7 @@ Example:
qcom,msm_bus,num_paths = <1>;
qcom,no-clock-support;
qcom,appsbl-qseecom-support;
qcom,fde-key-size;
qcom,msm_bus,vectors =
<55 512 0 0>,
<55 512 3936000000 393600000>,
Expand All @@ -72,6 +74,7 @@ Example: The following dts setup is the same as the example above.
qcom,msm_bus,num_paths = <1>;
qcom,no-clock-support;
qcom,appsbl-qseecom-support;
qcom,fde-key-size;
qcom,msm_bus,vectors =
<55 512 0 0>,
<55 512 3936000000 393600000>,
Expand Down
21 changes: 21 additions & 0 deletions drivers/misc/qseecom.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
#define QSEECOM_STATE_NOT_READY 0
#define QSEECOM_STATE_SUSPEND 1
#define QSEECOM_STATE_READY 2
#define QSEECOM_ICE_FDE_KEY_SIZE_MASK 2

/*
* default ce info unit to 0 for
Expand All @@ -110,6 +111,12 @@ enum qseecom_clk_definitions {
CLK_SFPB,
};

enum qseecom_ice_key_size_type{
QSEECOM_ICE_FDE_KEY_SIZE_16_BYTE = (0 << QSEECOM_ICE_FDE_KEY_SIZE_MASK),
QSEECOM_ICE_FDE_KEY_SIZE_32_BYTE = (1 << QSEECOM_ICE_FDE_KEY_SIZE_MASK),
QSEE_ICE_FDE_KEY_SIZE_UNDEFINED = (0xF << QSEECOM_ICE_FDE_KEY_SIZE_MASK),
};

enum qseecom_client_handle_type {
QSEECOM_CLIENT_APP = 1,
QSEECOM_LISTENER_SERVICE,
Expand Down Expand Up @@ -221,6 +228,7 @@ struct qseecom_control {
bool support_bus_scaling;
bool support_fde;
bool support_pfe;
bool fde_key_size;
uint32_t cumulative_mode;
enum qseecom_bandwidth_request_mode current_mode;
struct timer_list bw_scale_down_timer;
Expand Down Expand Up @@ -5451,6 +5459,11 @@ static int qseecom_create_key(struct qseecom_dev_handle *data,
goto free_buf;
}

if (qseecom.fde_key_size)
flags |= QSEECOM_ICE_FDE_KEY_SIZE_32_BYTE;
else
flags |= QSEECOM_ICE_FDE_KEY_SIZE_16_BYTE;

generate_key_ireq.flags = flags;
generate_key_ireq.qsee_command_id = QSEOS_GENERATE_KEY;
memset((void *)generate_key_ireq.key_id,
Expand Down Expand Up @@ -5669,6 +5682,12 @@ static int qseecom_update_key_user_info(struct qseecom_dev_handle *data,
}

ireq.qsee_command_id = QSEOS_UPDATE_KEY_USERINFO;

if (qseecom.fde_key_size)
flags |= QSEECOM_ICE_FDE_KEY_SIZE_32_BYTE;
else
flags |= QSEECOM_ICE_FDE_KEY_SIZE_16_BYTE;

ireq.flags = flags;
memset(ireq.key_id, 0, QSEECOM_KEY_ID_SIZE);
memset((void *)ireq.current_hash32, 0, QSEECOM_HASH_SIZE);
Expand Down Expand Up @@ -8138,6 +8157,8 @@ static int qseecom_probe(struct platform_device *pdev)
"qcom,commonlib64-loaded-by-uefi");
pr_debug("qseecom.commonlib64-loaded-by-uefi = 0x%x",
qseecom.commonlib64_loaded);
qseecom.fde_key_size = of_property_read_bool((&pdev->dev)->of_node,
"qcom,fde-key-size");
qseecom.no_clock_support =
of_property_read_bool((&pdev->dev)->of_node,
"qcom,no-clock-support");
Expand Down

0 comments on commit 927b944

Please sign in to comment.