0
$\begingroup$

Let's suppose we have the plaintext, 14/16 char of the key and the first 2 and the last 36 chars of encrypted data (that is 64 char long). What I want is to find the IV. The cipher algorithm is AES (I think 128).

As I said, both the Key and the IV are 16 char long, the plaintext is exactly 32 char long and the cyphertext produced is 64.

What tool / process can I use to find the IV knowing all of this stuff? Note that I don't know the full key, but I have a big part of it, so probably some bruteforce is needed.

$\endgroup$
  • 6
    $\begingroup$ This very much sounds like a homework problem. Go re-read how AES works, and pay special attention to how the IV, plaintext, and key are used to create the first block of ciphertext. You've got a bit of an a = f(b, x) situation where you have everything you need to solve for x, but you need to understand a bit better how f() works. $\endgroup$ – Mike Ounsworth Mar 27 at 18:05
  • $\begingroup$ I'm implicitly assuming that the mode of operation is CBC. I think here the char=byte. if the message is 32 byte => you need padding and for CBC the most common is the PKCS#7 padding. The value is 16 0x10 in hex. By using this and the last two ciphertexts one can find the key by looking the small 16-bit key search in known plaintetext attack. There are 4 bocks since usullay the IV is prepended to the ciphertext. It is not clear about the knowledge of the plaintext. If it is not known, one cannot find the IV, if known, it is a simple implementation... $\endgroup$ – kelalaka Mar 28 at 20:18
  • $\begingroup$ Yes, it's AES with CBC mode. The plaintext is fully known. $\endgroup$ – G0D0T Mar 28 at 22:31
  • 2
    $\begingroup$ Then it is a simple implementation. Find the key by the last encryption, the reveal, all. $\endgroup$ – kelalaka Mar 29 at 9:08
0
$\begingroup$

The way to solve the problem is the following:

  1. Bruteforcing the last 2 elements of the key.
  2. With that key, trying to decrypt the second block of the ciphertext.
  3. XORing that result with the second block of the plaintext.
  4. Comparing the new result with the partial first part of the ciphertext.
  5. If there is a correspondance we have found the right key (also the complete first ciphertext block), else go to step 1.

The last step is applying XOR to the decryption of the first block of the ciphertext and the first plaintext block. This should return the IV that we are looking for.

Since there is no padding (plaintext is 32 char long) this was not too difficult after a better understanding of the algorithm.

| improve this answer | |
$\endgroup$

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.