xeals / signal-back

Decrypt Signal encrypted backups outside the app
Apache License 2.0
700 stars 66 forks source link

Decryption does not yet work #1

Closed xeals closed 6 years ago

xeals commented 6 years ago

The decryption process currently gets hung on up a non-matching MAC between what the backup has and what we're expecting.

My major frustration and confusion at the moment is that the Java implementation allows for a 10-byte MAC, but the Rust crypto library produces 32-byte MACs following the same steps; obviously there's not going to be a time when these are equivalent. I'm not sure if it's a fundamental difference in how the Rust and Java libraries work.

I can process what I've written for the decryption process, but something along the line isn't exactly as it should be compared to the Java implementation. I'm diving into source for both languages to see where they differ. If anyone can point me to an open implementation of the javax.crypto library, I'd be grateful (as my version of OpenJDK doesn't have it).

xeals commented 6 years ago

Update: I've traced down the only issue to be the difference in how the Java and Rust libraries implement their CTR AES decryption. Regardless of key size I'm not getting a decryptable result, so something's up with one of them.

xeals commented 6 years ago

Good news: I rewrote the thing in Go and their AES implementation seems to work.

Bad news: I've found a neat little situation with memory usage when decrypting attachments.

I'll scope out what the new issues are and set up some trackers for people. However, I am making progress.