Documentation on the encrypted backup format
I am trying to extract all messages from silence. The "unencrypted backup" feature skips MMSes so it is unusable for me (see #184 #739 (closed) #772 and a lot more others). So I am trying to decrypt the "encrypted backup". A documentation on that format would be more than welcome as it is pretty cryptic (pun intended).
What I have found is that basic messages are stored in a SQLite database databases/messages.db
. The decryption key is most likely in shared_prefs/SecureSMS-Preferences.xml
with master_secret
containing the (password encrypted) symmetric key.
I want to decrypt the database on my machine, I don't use java but python.
My entrypoint is https://git.silence.dev/Silence/Silence-Android/blob/master/src/org/smssecure/smssecure/crypto/MasterSecretUtil.java#L100. So I first try to verify the mac as described here: https://git.silence.dev/Silence/Silence-Android/blob/master/src/org/smssecure/smssecure/crypto/MasterSecretUtil.java#L344 but fail.
I believe the issue is when trying to reproduce the behavior from https://git.silence.dev/Silence/Silence-Android/blob/master/src/org/smssecure/smssecure/crypto/MasterSecretUtil.java#L300 which derives String passphrase, byte[] salt, int iterations
into a key.
SecretKeyFactory skf = SecretKeyFactory.getInstance("PBEWITHSHA1AND128BITAES-CBC-BC");
seems to imply an obsolete key derivation mechanism.
But code calling getKeyFromPassphrase
names the output pbkdf2
: https://git.silence.dev/Silence/Silence-Android/blob/master/src/org/smssecure/smssecure/crypto/MasterSecretUtil.java#L332
So I'm lost because I don't know how to validate it.
I removed the password before making the encrypted backup. I tried to use PBKDF2 on my old password, the empty string or the string "unencrypted" but none of them worked.
The other route (the obsolete PBEWITHSHA1AND128BITAES-CBC-BC
scheme) is not easier because outside the java world, nobody seems to implement it. The RFC even contains errors.
Could some documentation at least clarify all this?
(This would be even more useful for users to take their data out of the silence app since it doesn't seem to be maintained a lot)