Understanding generation of IV in CBC encryption I am trying to understand CBC encryption and have a question in two parts:


When generating the next block for encryption I XOR the next plaintext block with the current ciphertext as the initialisation vector. The next plaintext block is 16 bytes, the current ciphertext is, say, 120 bytes. Which part of the ciphertext do I use? Is it implementation specific? Could I use 16 bytes from position 40?
What is the advantage of XORing the next plaintext block with current ciphertext over XORing the next plaintext block with the current XORed plaintext block? My guess is that the second option produces predictable patterns.
The next plaintext block is 16 bytes, the current ciphertext is, say,
  120 bytes


No. With CBC you consider a block cipher which transforms a plaintext block (say of size 16  bytes) to a ciphertext block (of the exact same size). So a 120 bytes ciphertext block for a 16 byte block is nonsense.

This also follows from the formula of CBC, which is
$$C_0=IV,C_i=E_K(P_i\oplus C_{i-1})$$
As you can see, each ciphertext is an output of a block cipher and thus must have exactly the same size as the input.


  What is the advantage of XORing the next plaintext block with current
  ciphertext over XORing the next plaintext block with the current XORed
  plaintext block?


So this would be $P_0=IV,C_i=E_K(P_i\oplus P_{i-1})$. Indeed, this mode doesn't hide patterns, and as such this mode is not secure against a chosen plaintext attack as you can distinguish $m=(m_1\parallel m_2 \parallel m_3 \parallel m_4)$ from $m'=(m_1\parallel m_1 \parallel m_2 \parallel m_2)$ because the latter has the same ciphertext blocks at position 2 and 4 (because the plaintexts cancel each other out) whereas the former does not.

Also see "Plaintext block chaining, bad idea why?".