-1
$\begingroup$

I want to know is there any way to derive the initialization vector, if I know all the other details.

AES SHA 256bits CBC pkcs5padding

Input: Hello

Key: 123

Output: xORGCDL88sa8cUrK8JNSCQ==

Now, how to find IV?

$\endgroup$
3
  • $\begingroup$ Does the padding oracle attack is possible? If not, no! CBC mode is CPA secure. $\endgroup$ – kelalaka Oct 21 '20 at 9:27
  • 1
    $\begingroup$ @kelalaka: CBC mode is not CPA secure if the adversary knows the key $\endgroup$ – poncho Oct 21 '20 at 13:07
  • $\begingroup$ @poncho uh, The key is known. Forget security. The question is much easier than. use the libraries.. $\endgroup$ – kelalaka Oct 21 '20 at 13:09
1
$\begingroup$

I want to know is there any way to derive the initialization vector, if I know all the other details.

Well, the first block (16 bytes for AES) of CBC mode encryption is defined as:

$$C_0 = E_k( IV \oplus P_0 )$$

where $P_0$ is the first block of the padded plaintext, and $C_0$ is the first block of the ciphertext.

If you know $C_0, P_0, k$, then you can rearrange this into:

$$IV = P_0 \oplus D_k( C_0 )$$

where $D_k$ is the AES transform in decryption mode, based on key $k$.

This allows you to rederive the IV directly.

$\endgroup$
2
  • $\begingroup$ Nitpick, there should be one block with hello. $\endgroup$ – kelalaka Oct 21 '20 at 13:49
  • $\begingroup$ @kelalaka: that's why I said that $P_0$ is the first block of the padded plaintext; that is, the hello after padding is added $\endgroup$ – poncho Oct 21 '20 at 13:50

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.