1

I was wandering at superuser and I found this question: Compress and then encrypt, or vice-versa?

Nearly all files have a Magic Number at a certain position in them. So, I wonder if I can attack (to break encryption or reduce possiblities...) by guessing several popular file formats?

I am aware that my question is very general without mentioning any encryption method or file format but I'm also looking for a general answer.

Thanks!

5

Trying to use the encrypted and plain "magic numbers" to figure out the key is a type of known-plaintext attack. Modern encryption algorithms are highly resistant to this sort of thing -- typically, trying every possible key is the only known way to do it.

Magic numbers and other file structure makes it easier for an attacker to tell that their latest guess at the key was correct, but they don't reduce the number of guesses needed.

0

Not if the encryption is done correctly. What does "correctly" entail?

  1. A good, modern cipher is being used. The standard choice today is AES.
  2. Under most circumstances, authentication in the form of a MAC is required as well. Without authentication, ciphertext is malleable. An attacker can modify bits of the ciphertext to say whatever he wants when it's decrypted. This is made much easier when there is data in a fixed position (say in the case of Magic Numbers of a file or a HTTP header).
  • Note that in the real world, malleability can be very hard to exploit. For example, generating a valid PNG header has a complexity upwards of 2^96: 12 of the first 16 bytes of the file are fixed, and the remaining four are restricted by the length of the file. – Mark Jan 31 '15 at 19:48
  • @Mark Depends on the cipher. With a stream cipher (or CTR or OFB modes of a block cipher, which just makes a stream cipher), it's quite easy to exploit. – cpast Jan 31 '15 at 22:29
  • Without encryption - do you mean without a MAC? – SilverlightFox Feb 2 '15 at 10:57
  • @SilverlightFox Yes, my bad. :) – Ayrx Feb 2 '15 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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