29

Using the SD card as Adopted Storage encrypts it. How can it be decrypted?

  • 2
    Downvoter(s): Note this is a "self-answered" question, sharing knowledge in wiki-style. So before deciding on a vote, check out the answer as well :) – Izzy May 21 '16 at 20:13
  • 1
    @Izzy here made them in to two question and answer here – poqdavid May 21 '16 at 20:39
  • Thanks! Adjusted the other one a little (no need for the SDK, and .exe would restrict it to Windows ;), updated our adoptable-storage tag-wiki and upvoted both your answers. Now you've enough rep to enter our chat room if you like :) – Izzy May 21 '16 at 20:47
  • I think current versions of Android do not use the term Adopted Storage they use SD card formatted as internal storage. – pabouk Dec 23 '18 at 18:09
25

How to decrypt adopted storage.

  1. Your device must be rooted.
  2. Using a file browser like ES Explorer, browse to /data/misc/vold.
  3. The .key file there is the encryption key of your adopted storage.
  4. Open that file with a hex editor to view the 16-byte key.
  5. On any GNU/Linux distro you can do this first mount your SD card, in my case SD card was mounted at /dev/sdb2.
  6. Then run this command:

    dmsetup create crypt1 --table "0 `blockdev --getsize /dev/sdb2` crypt aes-cbc-essiv:sha256 <Put the 16-byte hex key here> 0 /dev/sdb2 0"
    

    Some types of errors/warnings can be ignored.

  7. If your key is correct you can mount it by mount -t ext4 /dev/mapper/crypt1 /mnt/1/

  8. Finally you can run cd /mnt/1 to browse the decrypted storage.
  • 2
    Are you certain you came up with all of this on your own? I've doubts given this search query: google.co.in/… – Firelord May 21 '16 at 21:29
  • 2
    In that case consider explaining in detail the step 5. If possible, provide sources to support your technical claim. Thanks! – Firelord May 21 '16 at 21:46
  • 2
    Related: Corrupt SD card formatted as internal storage. The answer is similar, but gives an alternative approach to finding the 16-byte key. – Izzy May 22 '16 at 16:05
  • 1
    @zerwas the right thing is that you copy your key after making your SD as internal, but you can for sure encrypt your storage same as android do and make a key then put it there it will work but if you copy your key once its done by the phone it will be much simpler – poqdavid Jul 8 '16 at 19:02
  • 2
    You can use hexdump -e '1/1 "%.2x"' the_key_file.key to convert binary to hex. – Dzwiedziu-nkg Aug 23 '16 at 16:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.