Due to some platform restrictions our decryption algorithm can only handle up to 1 million bytes. The string we receive is larger, having been generated by AES in cipher block chaining (CBC) mode, with PKCS5 padding.

Is it possible to somehow split the encrypted data and decrypt the parts?

  • 2
    $\begingroup$ What mode of operation is being used? AES only encrypts blocks of 128bits. $\endgroup$ – Cryptographeur Dec 6 '13 at 14:03
  • $\begingroup$ We use cipher block chaining (CBC) and PKCS5 padding. $\endgroup$ – h9nry Dec 6 '13 at 14:06
  • $\begingroup$ With no authentication? This tends to be a risky scenario to be in, since unauthenticated encryption may be malleable. $\endgroup$ – Cryptographeur Dec 6 '13 at 14:16
  • 2
    $\begingroup$ No, authenticated encryption is about ensuring two things: privacy (no-one can read our encrypted messages) and non-malleability (no-one can create a fake message). Hopefully this blogpost will explain better than I can here $\endgroup$ – Cryptographeur Dec 6 '13 at 14:24
  • 1
    $\begingroup$ In the hopes of deriving a clearer explanation that "because you should!", I've started this question - hopefully it'll be of use. $\endgroup$ – Cryptographeur Dec 10 '13 at 16:04

Absolutely. The key point is that, whilst in CBC mode, the encryption can be thought of as using the previous ciphertext as the IV - have a look at this diagram from wikipedia: CBC decryption

I assume from what you've said that you have a function that will "do" AES-CBC decryption on large amounts of data, and you wish to use this. So, you simply run: $$ D_k^{IV}(c_1\ ||c_2\ ||\dots||c_n\ ) = m_1\ ||m_2\ ||\dots||m_n\ \\ D_k^{c_n}(c_{n+1}||c_{n+2}||\dots||c_{2n}) = m_{n+1}||m_{n+2}||\dots||m_{2n} $$

That is, wherever you 'break' the flow from the CBC output, you simply use the previous ciphertext as the IV to start the next section.

| improve this answer | |
  • $\begingroup$ Im trying to do this because of a platform limitation But for Encryption. But here is my problem. After the first 16bytes is encrypted the result is 32bytes... so i cannot pass it as an IV for the next iteration. any help ? $\endgroup$ – spaceMonkey May 15 '17 at 10:16

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.