1
$\begingroup$

Context: an encryption game from overthewire (the link to it: https://overthewire.org/wargames/krypton/krypton6.html, also good for more info) where given the ciphertext, one must obtain the plaintext.

On this level, we have access to a binary that encrypts any file by stream cipher, using a key from a file we do not have access (keyfile.dat) and a random number. We also have a hint: 8 bit LFSR.

My question is the following. Why can't I get back the plaintext encrypting the ciphertext?

My two assumptions for this claim are:

1) We're dealing with stream cipher, so encrypting the ciphertext should always give the plaintext, as long as the keystream is the same in both cases, what leads me to the second point;

2) I tried to encrypt two different files but with the same content (text) and the encrypted output in both cases was the same, so the keystream must be equal.

I know I'm wrong, as encrypting the ciphertext doesn't give me the plaintext, but rather some non-sense-random-even-more-encrypted file. Can you help me understand what's wrong with my reasoning?

Thanks in advance for any help.

$\endgroup$
1
$\begingroup$

In a stream cipher, encrypting the ciphertext should always give the plaintext

That's true for the appropriate definition of "ciphertext", which implies it is the same size as the plaintext; and the same Initialisation Vector (the "random number" I guess, hereafter IV) is used.

I suspect the experiment that attempts encrypting the ciphertext again actually encrypts the output of the encryption program, rather than the ciphertext as defined above. The output of the encryption program must somewhat include the ciphertext, but there are common practices that may explain why the experience attempted fails, including

  • The IV is typically included in the output of the encryption, to facilitate decryption. The simplest is it is at start, and the actual ciphertext follows.
  • The ciphertext might be reencoded, e.g. using Base64, headers/trailers..

Next actions could be comparing input and output size for the encryption binary, trying to locate the IV and actual ciphertext, and redoing the experiment using only the actual ciphertext as input of the re-encryption.

Alternatively, another property of a stream cipher can help: encrypt two plaintext that differ by their first byte, under the same IV, and compare the ciphertexts. The location of the difference tells where the actual ciphertext starts.

$\endgroup$
2
  • $\begingroup$ I suspect the experiment that attempts encrypting the ciphertext again actually encrypts the output of the encryption program, rather than the ciphertext as defined above. - I'm not sure if I understood this, could you explain a little better? $\endgroup$
    – arpg
    Sep 12 at 13:40
  • $\begingroup$ @arpg: it could be the encryption program outputs more than the ciphertext. Like IV and ciphertext. So that you don't re-encrypt just the ciphertext, and thus don't get the expected result. $\endgroup$
    – fgrieu
    Sep 12 at 15:15

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.