summaryrefslogtreecommitdiffstats
path: root/cryptfs_hw.c
diff options
context:
space:
mode:
authorAnilKumar Chimata <anilc@codeaurora.org>2014-12-18 00:27:44 +0530
committerZhao Wei Liew <zhaoweiliew@gmail.com>2017-02-26 09:26:14 +0000
commit85b5399df1b081000a0982e6e1234523ca9abf9e (patch)
tree2670bb2085e7db3b582d73e14bada9dd7332a162 /cryptfs_hw.c
parentd1e1e0b06131fb6fb88e3d570f479e89db56406d (diff)
downloadandroid_vendor_qcom_opensource_cryptfs_hw-85b5399df1b081000a0982e6e1234523ca9abf9e.tar.gz
android_vendor_qcom_opensource_cryptfs_hw-85b5399df1b081000a0982e6e1234523ca9abf9e.tar.bz2
android_vendor_qcom_opensource_cryptfs_hw-85b5399df1b081000a0982e6e1234523ca9abf9e.zip
cryptfs_hw: Add support for is_hw_fde_enabled routinereplicant-6.0-0001
Add support for is_hw_fde_enabled routine to get the fde status based on the chipset. Change-Id: I7e0e078da6668e347a78de487da44ddc331bd478 (cherry picked from commit 144e832ff3e16af20d3975aeec4a64bf8f80a8a3)
Diffstat (limited to 'cryptfs_hw.c')
-rwxr-xr-xcryptfs_hw.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/cryptfs_hw.c b/cryptfs_hw.c
index 6695552..ff06c9f 100755
--- a/cryptfs_hw.c
+++ b/cryptfs_hw.c
@@ -64,6 +64,11 @@
/* Operations that be performed on HW based device encryption key */
#define SET_HW_DISK_ENC_KEY 1
#define UPDATE_HW_DISK_ENC_KEY 2
+#define MAX_DEVICE_ID_LENGTH 4 /* 4 = 3 (MAX_SOC_ID_LENGTH) + 1 */
+
+static unsigned int cpu_id[] = {
+ 239, /* MSM8939 SOC ID */
+};
#define QSEECOM_UP_CHECK_COUNT 10
@@ -235,6 +240,58 @@ unsigned int is_hw_disk_encryption(const char* encryption_mode)
return ret;
}
+/*
+ * By default HW FDE is enabled, if the execution comes to
+ * is_hw_fde_enabled() API then for specific device/soc id,
+ * HW FDE is disabled.
+ */
+#ifdef CONFIG_SWV8_DISK_ENCRYPTION
+unsigned int is_hw_fde_enabled(void)
+{
+ unsigned int device_id = -1;
+ unsigned int array_size;
+ unsigned int status = 1;
+ FILE *fd = NULL;
+ unsigned int i;
+ int ret = -1;
+ char buf[MAX_DEVICE_ID_LENGTH];
+
+ fd = fopen("/sys/devices/soc0/soc_id", "r");
+ if (fd) {
+ ret = fread(buf, 1, MAX_DEVICE_ID_LENGTH, fd);
+ fclose(fd);
+ } else {
+ fd = fopen("/sys/devices/system/soc/soc0/id", "r");
+ if (fd) {
+ ret = fread(buf, 1, MAX_DEVICE_ID_LENGTH, fd);
+ fclose(fd);
+ }
+ }
+
+ if (ret > 0) {
+ device_id = atoi(buf);
+ } else {
+ SLOGE("Failed to read device id");
+ return status;
+ }
+
+ array_size = sizeof(cpu_id) / sizeof(cpu_id[0]);
+ for (i = 0; i < array_size; i++) {
+ if (device_id == cpu_id[i]) {
+ status = 0;
+ break;
+ }
+ }
+
+ return status;
+}
+#else
+unsigned int is_hw_fde_enabled(void)
+{
+ return 1;
+}
+#endif
+
int is_ice_enabled(void)
{
char prop_storage[PATH_MAX];