# How to decrypt AES in CBC

i am having problems understanding how CBC works! I know that it is a chain and the IV is XORed with the PT but then what? I mean we encrypt it with key k and the result is the CT which we use for the next chain-XOR but my question is HOW the encryption works? For example in Stream ciphers i just had to XOR the K with the M (or C) to get my result, but on block ciphers i am completely lost...

-
Have a look at the drawings here then tell us what remains unclear – fgrieu Sep 11 '12 at 10:02

CBC is a block cipher mode of operation, not a cipher. It can work basically with any block cipher - the choice of the block cipher itself is independent (to a large extent) from the choice of the mode of operation.

Examples of well known block ciphers include AES, DES, TripleDES, Serpent, Blowfish etc.

The title of your question, however, asks about decrypting AES using CBC mode operation. In which case you should be using AES, $P_t = \operatorname{AES-128-DEC}_k(C_t) \operatorname{XOR} C_{t-1}$. AES decryption is available in many crypto libraries (for example libtomcrypt, Crypto++, openssl, Java Cryptography Extensions, Python Cryptography Toolkit), and you can even use online AES "calculators" such as this one.

-
yes but lets say that the key is 10101010 and the IV 01010101 how do i encrypt the 11110000 i need to know the procedure AFTER the XOR operation. – angelo Sep 11 '12 at 9:12
CBC only says basically that C_t = ENC_k(C_{t-1} XOR P_t). ENC_k here is the encryption operation of the block cipher (whichever you choose, for example AES-128) with the key k. That's all. The details are a matter of the choice of the specific block cipher. – Harel Sep 11 '12 at 9:15
ok i get what ou are syaing but just to make it more clear, i am following a cryptography course in coursera.org where given the k and the IV i have to decrypt a CT, so i am doing the flowing: (IV xor c_1) xor k (for the first block) and (m_1 xor c_2) xor k (for the second one and so on) but that does not return any reasonable result what am i doin wrong? – angelo Sep 11 '12 at 9:20
If I understand you correctly, what you're doing is correct only if your "block cipher" is simple XOR, which in all likelihood it is not (unless the guys in Coursera gave you a somewhat esoteric assignment). More likely you should be using some "real" block cipher here. Furthermore, a ciphertext will usually not look "reasonable" no matter what. You know you have it right when you can decrypt it back to plaintext. – Harel Sep 11 '12 at 9:22
ok then is there any specific method to follow other than XORing? How would you normally decrypt/encrypt with CBC method given a K and a IV?(just give me a link/source if you will/have so i dont waste your time on newbie questions :D) – angelo Sep 11 '12 at 9:29