General descryption
The block cipher is an operation that lives in the box [block cipher encryption]. A block cipher can do two things: encrypt and decrypt. It is parametrized by a key, which is one of two inputs. The other input is a block of data. The output is the keyed permutation of that block of data. A permutation is a 1:1 relation; each input block of data will have a relationship with exactly one output block of data.
The block size of a block cipher is always the same. As there is a 1:1 relationship the input and output block sizes are identical. The key size is not directly related to the block size. Block ciphers usually have a key schedule to calculate the sub keys used for the various rounds that are invariably present in a block cipher. For DES the block size is 64 bits / 8 bytes. The key size is 56 bits or 7 bytes, not counting the parity bits.
In a block cipher mode of encryption the key always stays the same for the cipher. A key schedule can be expensive, so this is one good reason not to change keys for the block cipher for a mode of operation. The block size remains static as well.
Example: DES in OFB mode
Now if DES is inserted in the above picture showing OFB then the mode runs with a block size of 8 bytes. The block cipher therefore receives 8 bytes: the IV (initialization vector). So you can derive that the IV must be 8 bytes for OFB. This is encrypted, giving the 8 byte permutation of the original 8 bytes in return. This encrypted IV is then XORed with 8 bytes of plaintext, giving 8 bytes of ciphertext. The encrypted IV is also used as next vector to allow for the encryption of the next block of plaintext.
Why modes of operation are required
We need these modes because DES itself is completely deterministic. Giving a key you can only get the same block of output for each specific block of input. This means that if we use DES then we either have to keep to one block for each key, or we have to somehow introduce change. This change is brought by specifying a unique IV. The change is propagated to the next bytes using the mode. The mode of operation may have additional constraints besides uniqueness for the IV.
So in the end the output of the mode of operation should be indistinguishable from random. It's time to use another key if the user expects at some point that an identical block of output could be produced because the sheer amount of data being processed.
ECB
ECB is a special mode of operation: it basically just cuts the block in plaintext into block, encrypts each block and then stitches the encrypted blocks back together again. It is relatively unique in the sense that it doesn't use an IV. Because of that it is not secure, except when used on data that itself is unrelated and meaningless to an attacker. A good example would be a randomly generated key.
Notes:
- This mode above is also known as OFB-64 or OFB-N (N being the block size) as all 64 bits are used directly to calculate the ciphertext.