Merge "Adding support for eMMC based ICE"
This commit is contained in:
commit
6cd4c01354
|
@ -52,8 +52,11 @@
|
||||||
// wipe userdata partition once this error is received.
|
// wipe userdata partition once this error is received.
|
||||||
#define ERR_MAX_PASSWORD_ATTEMPTS -10
|
#define ERR_MAX_PASSWORD_ATTEMPTS -10
|
||||||
#define QSEECOM_DISK_ENCRYPTION 1
|
#define QSEECOM_DISK_ENCRYPTION 1
|
||||||
#define QSEECOM_ICE_DISK_ENCRYPTION 3
|
#define QSEECOM_UFS_ICE_DISK_ENCRYPTION 3
|
||||||
|
#define QSEECOM_SDCC_ICE_DISK_ENCRYPTION 4
|
||||||
#define MAX_PASSWORD_LEN 32
|
#define MAX_PASSWORD_LEN 32
|
||||||
|
#define QCOM_ICE_STORAGE_UFS 1
|
||||||
|
#define QCOM_ICE_STORAGE_SDCC 2
|
||||||
|
|
||||||
/* Operations that be performed on HW based device encryption key */
|
/* Operations that be performed on HW based device encryption key */
|
||||||
#define SET_HW_DISK_ENC_KEY 1
|
#define SET_HW_DISK_ENC_KEY 1
|
||||||
|
@ -66,11 +69,18 @@ static int (*qseecom_update_key)(int, void*, void*);
|
||||||
|
|
||||||
static int map_usage(int usage)
|
static int map_usage(int usage)
|
||||||
{
|
{
|
||||||
return (is_ice_enabled() && (usage == QSEECOM_DISK_ENCRYPTION)) ?
|
int storage_type = is_ice_enabled();
|
||||||
QSEECOM_ICE_DISK_ENCRYPTION : usage;
|
if (usage == QSEECOM_DISK_ENCRYPTION) {
|
||||||
|
if (storage_type == QCOM_ICE_STORAGE_UFS) {
|
||||||
|
return QSEECOM_UFS_ICE_DISK_ENCRYPTION;
|
||||||
|
}
|
||||||
|
else if (storage_type == QCOM_ICE_STORAGE_SDCC) {
|
||||||
|
return QSEECOM_SDCC_ICE_DISK_ENCRYPTION ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return usage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static unsigned char* get_tmp_passwd(const char* passwd)
|
static unsigned char* get_tmp_passwd(const char* passwd)
|
||||||
{
|
{
|
||||||
int passwd_len = 0;
|
int passwd_len = 0;
|
||||||
|
@ -185,34 +195,20 @@ unsigned int is_hw_disk_encryption(const char* encryption_mode)
|
||||||
|
|
||||||
int is_ice_enabled(void)
|
int is_ice_enabled(void)
|
||||||
{
|
{
|
||||||
/* If (USE_ICE_FLAG) => return 1
|
char prop_storage[PATH_MAX];
|
||||||
* if (property set to use gpce) return 0
|
int storage_type = 0;
|
||||||
* we are using property to test UFS + GPCE, even though not required
|
int fd;
|
||||||
* if (storage is ufs) return 1
|
|
||||||
* else return 0 so that emmc based device can work properly
|
|
||||||
*/
|
|
||||||
#ifdef USE_ICE_FOR_STORAGE_ENCRYPTION
|
|
||||||
SLOGD("Ice enabled = true");
|
|
||||||
return 1;
|
|
||||||
#else
|
|
||||||
char enc_hw_type[PATH_MAX];
|
|
||||||
char prop_storage[PATH_MAX];
|
|
||||||
int ice = 0;
|
|
||||||
int i;
|
|
||||||
if (property_get("crypto.fde_enc_hw_type", enc_hw_type, "")) {
|
|
||||||
if(!strncmp(enc_hw_type, "gpce", PROPERTY_VALUE_MAX)) {
|
|
||||||
SLOGD("GPCE would be used for HW FDE");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (property_get("ro.boot.bootdevice", prop_storage, "")) {
|
if (property_get("ro.boot.bootdevice", prop_storage, "")) {
|
||||||
if(strstr(prop_storage, "ufs")) {
|
if (strstr(prop_storage, "ufs")) {
|
||||||
SLOGD("ICE would be used for HW FDE");
|
/* All UFS based devices has ICE in it. So we dont need
|
||||||
return 1;
|
* to check if corresponding device exists or not
|
||||||
}
|
*/
|
||||||
|
storage_type = QCOM_ICE_STORAGE_UFS;
|
||||||
|
} else if (strstr(prop_storage, "sdhc")) {
|
||||||
|
if (access("/dev/icesdcc", F_OK) != -1)
|
||||||
|
storage_type = QCOM_ICE_STORAGE_SDCC;
|
||||||
}
|
}
|
||||||
SLOGD("GPCE would be used for HW FDE");
|
}
|
||||||
return 0;
|
return storage_type;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue