More Samsung sdcard crypto fixes
This commit is contained in:
@@ -133,6 +133,9 @@ typedef int (*mount_ecryptfs_drive_t)(
|
||||
int unmount_ecryptfs_drive(
|
||||
const char *source);
|
||||
|
||||
typedef int (*unmount_ecryptfs_drive_t)(
|
||||
const char *source);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // #ifndef __LIBCRYPT_SAMSUNG_H__
|
||||
|
||||
@@ -11,25 +11,6 @@
|
||||
#include "include/libcrypt_samsung.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void xconvert_key_to_hex_ascii(unsigned char *master_key, unsigned int keysize,
|
||||
char *master_key_ascii)
|
||||
{
|
||||
unsigned int i, a;
|
||||
unsigned char nibble;
|
||||
|
||||
for (i=0, a=0; i<keysize; i++, a+=2) {
|
||||
/* For each byte, write out two ascii hex digits */
|
||||
nibble = (master_key[i] >> 4) & 0xf;
|
||||
master_key_ascii[a] = nibble + (nibble > 9 ? 0x37 : 0x30);
|
||||
|
||||
nibble = master_key[i] & 0xf;
|
||||
master_key_ascii[a+1] = nibble + (nibble > 9 ? 0x37 : 0x30);
|
||||
}
|
||||
|
||||
/* Add the null termination */
|
||||
master_key_ascii[a] = '\0';
|
||||
|
||||
}
|
||||
|
||||
int decrypt_EDK(
|
||||
dek_t *dek, const edk_payload_t *edk, /*const*/ char *passwd)
|
||||
@@ -66,3 +47,19 @@ int mount_ecryptfs_drive(
|
||||
return r;
|
||||
}
|
||||
|
||||
int unmount_ecryptfs_drive(
|
||||
const char *source)
|
||||
{
|
||||
void *lib = dlopen("libsec_ecryptfs.so", RTLD_LAZY);
|
||||
if(!lib)
|
||||
return -100;
|
||||
|
||||
int r = -101;
|
||||
unmount_ecryptfs_drive_t sym = (unmount_ecryptfs_drive_t)dlsym(lib, "unmount_ecryptfs_drive");
|
||||
if(sym)
|
||||
r = sym(source);
|
||||
|
||||
dlclose(lib);
|
||||
|
||||
return r;
|
||||
}
|
||||
+14
-1
@@ -705,7 +705,7 @@ bool TWPartition::Mount(bool Display_Error) {
|
||||
return false;
|
||||
} else {
|
||||
#ifdef TW_INCLUDE_CRYPTO_SAMSUNG
|
||||
if (EcryptFS_Password.size() > 0) {
|
||||
if (EcryptFS_Password.size() > 0 && PartitionManager.Mount_By_Path("/data", false)) {
|
||||
if (mount_ecryptfs_drive(EcryptFS_Password.c_str(), Mount_Point.c_str(), Mount_Point.c_str(), 0) != 0) {
|
||||
if (Display_Error)
|
||||
LOGE("Unable to mount ecryptfs for '%s'\n", Mount_Point.c_str());
|
||||
@@ -735,6 +735,19 @@ bool TWPartition::UnMount(bool Display_Error) {
|
||||
if (never_unmount_system == 1 && Mount_Point == "/system")
|
||||
return true; // Never unmount system if you're not supposed to unmount it
|
||||
|
||||
#ifdef TW_INCLUDE_CRYPTO_SAMSUNG
|
||||
if (EcryptFS_Password.size() > 0) {
|
||||
if (unmount_ecryptfs_drive(Mount_Point.c_str()) != 0) {
|
||||
if (Display_Error)
|
||||
LOGE("Unable to unmount ecryptfs for '%s'\n", Mount_Point.c_str());
|
||||
else
|
||||
LOGI("Unable to unmount ecryptfs for '%s'\n", Mount_Point.c_str());
|
||||
} else {
|
||||
LOGI("Successfully unmounted ecryptfs for '%s'\n", Mount_Point.c_str());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!Symlink_Mount_Point.empty())
|
||||
umount(Symlink_Mount_Point.c_str());
|
||||
|
||||
|
||||
@@ -1635,7 +1635,7 @@ int TWPartitionManager::Decrypt_Device(string Password) {
|
||||
property_get("ro.crypto.sd_fs_crypto_blkdev", crypto_blkdev_sd, "error");
|
||||
if (strcmp(crypto_blkdev_sd, "error") == 0) {
|
||||
LOGE("Error retrieving decrypted data block device.\n");
|
||||
} else if(TWPartition* emmc = Find_Partition_By_Path(TW_INTERNAL_STORAGE_PATH)){
|
||||
} else if(TWPartition* emmc = Find_Partition_By_Path(EXPAND(TW_INTERNAL_STORAGE_PATH))){
|
||||
emmc->Is_Decrypted = true;
|
||||
emmc->Decrypted_Block_Device = crypto_blkdev_sd;
|
||||
emmc->Setup_File_System(false);
|
||||
|
||||
Reference in New Issue
Block a user