diff options
author | AnilKumar Chimata <anilc@codeaurora.org> | 2015-05-22 12:53:45 +0530 |
---|---|---|
committer | Zhao Wei Liew <zhaoweiliew@gmail.com> | 2017-02-12 20:43:57 +0800 |
commit | 0b9f6f6fc7acc44d6d99a24ec224d123d6f6b456 (patch) | |
tree | 49b36399dc28fa824b47d9c1d813b437bbfab709 | |
parent | 53ae3b48568b97117d81cfb3ea938f8a3a4acb5d (diff) | |
download | android_vendor_qcom_opensource_cryptfs_hw-0b9f6f6fc7acc44d6d99a24ec224d123d6f6b456.tar.gz android_vendor_qcom_opensource_cryptfs_hw-0b9f6f6fc7acc44d6d99a24ec224d123d6f6b456.tar.bz2 android_vendor_qcom_opensource_cryptfs_hw-0b9f6f6fc7acc44d6d99a24ec224d123d6f6b456.zip |
cryptfs_hw: Update APIs to take old password
Update cryptfs_hw APIs to take old password along with the new
passowrd.
Change-Id: Ieca5c4bac36ba4bb2371d2f3bbe0cadf79e256d7
-rwxr-xr-x | cryptfs_hw.c | 26 | ||||
-rwxr-xr-x | cryptfs_hw.h | 2 |
2 files changed, 13 insertions, 15 deletions
diff --git a/cryptfs_hw.c b/cryptfs_hw.c index a7164ab..ce522e5 100755 --- a/cryptfs_hw.c +++ b/cryptfs_hw.c @@ -63,7 +63,6 @@ #define UPDATE_HW_DISK_ENC_KEY 2 static int loaded_library = 0; -static unsigned char current_passwd[MAX_PASSWORD_LEN]; static int (*qseecom_create_key)(int, void*); static int (*qseecom_update_key)(int, void*, void*); static int (*qseecom_wipe_key)(int); @@ -155,25 +154,25 @@ static int load_qseecom_library() * For NON-ICE targets, it would return 0 on success. On ICE based targets, * it would return key index in the ICE Key LUT */ -static int set_key(const char* passwd, const char* enc_mode, int operation) +static int set_key(const char* currentpasswd, const char* passwd, const char* enc_mode, int operation) { int err = -1; if (is_hw_disk_encryption(enc_mode) && load_qseecom_library()) { unsigned char* tmp_passwd = get_tmp_passwd(passwd); + unsigned char* tmp_currentpasswd = get_tmp_passwd(currentpasswd); if(tmp_passwd) { - if (operation == UPDATE_HW_DISK_ENC_KEY) - err = qseecom_update_key(map_usage(QSEECOM_DISK_ENCRYPTION), current_passwd, tmp_passwd); - else if (operation == SET_HW_DISK_ENC_KEY) + if (operation == UPDATE_HW_DISK_ENC_KEY) { + if (tmp_currentpasswd) + err = qseecom_update_key(map_usage(QSEECOM_DISK_ENCRYPTION), tmp_currentpasswd, tmp_passwd); + } else if (operation == SET_HW_DISK_ENC_KEY) { err = qseecom_create_key(map_usage(QSEECOM_DISK_ENCRYPTION), tmp_passwd); - - if(err >= 0) { - memset(current_passwd, 0, MAX_PASSWORD_LEN); - memcpy(current_passwd, tmp_passwd, MAX_PASSWORD_LEN); - } else { + } + if(err < 0) { if(ERR_MAX_PASSWORD_ATTEMPTS == err) wipe_userdata(); } free(tmp_passwd); + free(tmp_currentpasswd); } } return err; @@ -181,13 +180,12 @@ static int set_key(const char* passwd, const char* enc_mode, int operation) int set_hw_device_encryption_key(const char* passwd, const char* enc_mode) { - return set_key(passwd, enc_mode, SET_HW_DISK_ENC_KEY); + return set_key(NULL, passwd, enc_mode, SET_HW_DISK_ENC_KEY); } -int update_hw_device_encryption_key(const char* newpw, const char* enc_mode) +int update_hw_device_encryption_key(const char* oldpw, const char* newpw, const char* enc_mode) { - - return set_key(newpw, enc_mode, UPDATE_HW_DISK_ENC_KEY); + return set_key(oldpw, newpw, enc_mode, UPDATE_HW_DISK_ENC_KEY); } unsigned int is_hw_disk_encryption(const char* encryption_mode) diff --git a/cryptfs_hw.h b/cryptfs_hw.h index c7b1746..5d4881c 100755 --- a/cryptfs_hw.h +++ b/cryptfs_hw.h @@ -34,7 +34,7 @@ extern "C" { #endif int set_hw_device_encryption_key(const char*, const char*); -int update_hw_device_encryption_key(const char*, const char*); +int update_hw_device_encryption_key(const char*, const char*, const char*); int wipe_hw_device_encryption_key(const char*); unsigned int is_hw_disk_encryption(const char*); int is_ice_enabled(void); |