# How would you explain stateful encryption?

I have recently started reading on encryption protocols and their counter attacks. I came across the term Stateful Encryption particularly used in encrypting data that is stored in the cloud. So far I think it is just another variable that is used to calculate ciphertext and gets updated after every generation and storage of ciphertext from a plaintext. Can you explain why statefulness was needed and how it solved that need?

Perhaps the simplest stateful encryption is CBC encryption with a block cipher $$E$$ (though that predates the term stateful encryption, which is not used for CBC). The stateless version of CBC would, for each plaintext block $$P_i$$, draw a random $$\text{IV}_i$$ and send cryptogram $$(\text{IV}_i,C_i=E(\text{IV}_i\oplus P_i))$$; this is secure from a confidentiality standpoint, but overall cause the ciphertext to be twice the size of the plaintext. While CBC encryption draws a single random $$\text{IV}$$, sends $$(\text{IV},C_0=E(\text{IV}\oplus P_0))$$ for the first packet, and $$(C_i=E(C_{i-1}\oplus P_i))$$ for all the next ones, thus reducing communication overhead to a single block. Here chunk is a block, and the state is simply the last block encrypted, initially $$\text{IV}$$.