I'd like to write an Android Application which automatically decrypts my Whatsapp Database, so I followed this tutorial and translated it into Java. But then I noticed that there is no openssl binary on Android so I asked google how to decrypt aes manually but I could not find something useful.
So basically I got this shell command
openssl enc -aes-256-cbc -d -nosalt -nopad -bufsize 16384 -in msgstore.db.crypt7.nohdr -K $k -iv $iv > msgstore.db
with $k being a 64 digit hex-string. But when I tried to use it as the key for the aes decryption I get an InvalidKeyException with the message "Unsupported key size: 64 bytes". When I execute this command at my computer I works perfectly.
I am currently using this java code to decrypt the database and it fails at cipher.init:
public void decryptDatabase(String k, String iv)
throws InvalidKeyException, InvalidAlgorithmParameterException,
NoSuchAlgorithmException, NoSuchPaddingException, IOException {
File extStore = Environment.getExternalStorageDirectory();
FileInputStream fis = new FileInputStream(extStore
+ "/WhatsApp/Databases/msgstore.db.crypt7.nohdr");
FileOutputStream fos = new FileOutputStream(extStore + "/Decrypted.db");
SecretKeySpec sks = new SecretKeySpec(k.getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
cipher.init(Cipher.DECRYPT_MODE, sks,
new IvParameterSpec(iv.getBytes()));
CipherInputStream cis = new CipherInputStream(fis, cipher);
int b;
byte[] d = new byte[8];
while ((b = cis.read(d)) != -1) {
fos.write(d, 0, b);
}
fos.flush();
fos.close();
cis.close();
}
Please help me if you can :)
Thanks in advance, Citron