I am able to successfully unlock a corrupted Android encrypted SD card on desktop Linux using instructions from the Internet.
# dmsetup create crypt5 --table "0 `blockdev --getsize /dev/mmcblk0p2` crypt aes-cbc-essiv:sha256 HEXIDECIMALPASSPHRASEHERE 0 /dev/mmcblk0p2 0"
Recovery directly from the SD card using photorec was taking an unacceptable amount of time. As a compromise, I decided to start by making a disk image file from the encrypted partition so I can verify the integrity of the SD card an reuse it then recover the data from the image file later.
# dd if=/dev/mmcblk0p2 of=/home/crash/Documents/128gb.img iflag=direct oflag=dsync
Now the question is, "how do I unlock the disk image file?" Knowing that the disk image file is supposed to be identical to the original partition, I tried tweaking the original command to plug in the size of the block device and the location of disk image file.
# blockdev --getsize /dev/mmcblk0p2
Plug that in:
# dmsetup create crypt6 --table "0 250048479 crypt aes-cbc-essiv:sha256 HEXIDECIMALPASSPHRASEHERE 0 /home/crash/Documents/128gb.img 0"
This fails with the following error:
device-mapper: reload ioctl on crypt6 failed: Invalid argument Command failed
I don't see what went wrong. I would like to confirm that this disk image can be unlocked before I move on to wiping and testing the SD card.