From 7cc34529cd52b1522ed60497437851758312c066 Mon Sep 17 00:00:00 2001 From: AnilKumar Chimata Date: Thu, 14 Jun 2018 16:43:17 +0530 Subject: cryptfs: Allow vold to set encryption info Vold needs to set partition and ICE specific data before encryption starts. Change-Id: Ie721f35d7f5cbb486d1d3895e42f992fe4bc51bf --- cryptfs_hw.c | 22 ++++++++++++++++++++++ cryptfs_hw.h | 6 ++++++ 2 files changed, 28 insertions(+) diff --git a/cryptfs_hw.c b/cryptfs_hw.c index 859b108..65618df 100644 --- a/cryptfs_hw.c +++ b/cryptfs_hw.c @@ -66,6 +66,8 @@ #define CRYPTFS_HW_WIPE_KEY_FAILED -8 #define CRYPTFS_HW_CREATE_KEY_FAILED -7 +#define CRYPTFS_HW_ALGO_MODE_AES_XTS 0x3 + enum cryptfs_hw_key_management_usage_type { CRYPTFS_HW_KM_USAGE_DISK_ENCRYPTION = 0x01, CRYPTFS_HW_KM_USAGE_FILE_ENCRYPTION = 0x02, @@ -171,6 +173,26 @@ static int cryptfs_hw_wipe_key(enum cryptfs_hw_key_management_usage_type usage) return ret; } +#ifdef QSEECOM_IOCTL_SET_ICE_INFO +int set_ice_param(int flag) +{ + int qseecom_fd, ret = -1; + struct qseecom_ice_data_t ice_data; + qseecom_fd = open("/dev/qseecom", O_RDWR); + if (qseecom_fd < 0) + return ret; + ice_data.flag = flag; + ret = ioctl(qseecom_fd, QSEECOM_IOCTL_SET_ICE_INFO, &ice_data); + close(qseecom_fd); + return ret; +} +#else +int set_ice_param(int flag) +{ + return -1; +} +#endif + static int cryptfs_hw_clear_key(enum cryptfs_hw_key_management_usage_type usage) { int32_t ret; diff --git a/cryptfs_hw.h b/cryptfs_hw.h index e857c47..65321eb 100644 --- a/cryptfs_hw.h +++ b/cryptfs_hw.h @@ -33,12 +33,18 @@ extern "C" { #endif +/*This is equivalent of MAX_CRYPTO_TYPE_NAME_LEN*/ +#define CRYPTO_ALGO_LENGTH 64 +#define START_ENC 0x1 +#define START_ENCDEC 0x3 + int set_hw_device_encryption_key(const char*, const char*); int update_hw_device_encryption_key(const char*, const char*, const char*); int clear_hw_device_encryption_key(); unsigned int is_hw_disk_encryption(const char*); int is_ice_enabled(void); int should_use_keymaster(); +int set_ice_param(int flag); #ifdef __cplusplus } -- cgit v1.2.3