diff options
author | Ethan Yonker <dees_troy@teamw.in> | 2015-08-09 19:48:14 +0200 |
---|---|---|
committer | Ethan Yonker <dees_troy@teamw.in> | 2015-08-09 19:48:14 +0200 |
commit | bc85b63e78e5a68cc5c3a54e11a5c35e9349387a (patch) | |
tree | 2e96ad898eddd5b3c66bfda38e73215b07b879ba /partition.cpp | |
parent | ORS: Report success if AOSP script succeeds (diff) | |
download | android_bootable_recovery-bc85b63e78e5a68cc5c3a54e11a5c35e9349387a.tar android_bootable_recovery-bc85b63e78e5a68cc5c3a54e11a5c35e9349387a.tar.gz android_bootable_recovery-bc85b63e78e5a68cc5c3a54e11a5c35e9349387a.tar.bz2 android_bootable_recovery-bc85b63e78e5a68cc5c3a54e11a5c35e9349387a.tar.lz android_bootable_recovery-bc85b63e78e5a68cc5c3a54e11a5c35e9349387a.tar.xz android_bootable_recovery-bc85b63e78e5a68cc5c3a54e11a5c35e9349387a.tar.zst android_bootable_recovery-bc85b63e78e5a68cc5c3a54e11a5c35e9349387a.zip |
Diffstat (limited to '')
-rw-r--r-- | partition.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/partition.cpp b/partition.cpp index e612be34f..8c5b412a7 100644 --- a/partition.cpp +++ b/partition.cpp @@ -52,6 +52,8 @@ extern "C" { #ifdef TW_INCLUDE_CRYPTO #include "crypto/lollipop/cryptfs.h" +#else + #define CRYPT_FOOTER_OFFSET 0x4000 #endif } #ifdef HAVE_SELINUX @@ -1529,6 +1531,46 @@ bool TWPartition::Wipe_Encryption() { Is_Decrypted = false; Is_Encrypted = false; Find_Actual_Block_Device(); + if (Crypto_Key_Location == "footer") { + int newlen, fd; + if (Length != 0) { + newlen = Length; + if (newlen < 0) + newlen = newlen * -1; + } else { + newlen = CRYPT_FOOTER_OFFSET; + } + if ((fd = open(Actual_Block_Device.c_str(), O_RDWR)) < 0) { + gui_print_color("warning", "Unable to open '%s' to wipe crypto key\n", Actual_Block_Device.c_str()); + } else { + unsigned int block_count; + if ((ioctl(fd, BLKGETSIZE, &block_count)) == -1) { + gui_print_color("warning", "Unable to get block size for wiping crypto footer.\n"); + } else { + off64_t offset = ((off64_t)block_count * 512) - newlen; + if (lseek64(fd, offset, SEEK_SET) == -1) { + gui_print_color("warning", "Unable to lseek64 for wiping crypto footer.\n"); + } else { + void* buffer = malloc(newlen); + if (!buffer) { + gui_print_color("warning", "Failed to malloc for wiping crypto footer.\n"); + } else { + memset(buffer, 0, newlen); + int ret = write(fd, buffer, newlen); + if (ret != newlen) { + gui_print_color("warning", "Failed to wipe crypto footer.\n"); + } else { + LOGINFO("Successfully wiped crypto footer.\n"); + } + } + } + } + close(fd); + } + } else { + string Command = "flash_image " + Crypto_Key_Location + " /dev/zero"; + TWFunc::Exec_Cmd(Command); + } if (Wipe(Fstab_File_System)) { Has_Data_Media = Save_Data_Media; if (Has_Data_Media && !Symlink_Mount_Point.empty()) { |