ythy / blog

Give everything a shot
6 stars 0 forks source link

Block cipher mode #101

Open ythy opened 6 years ago

ythy commented 6 years ago

Electronic Codebook (ECB)

The simplest of the encryption modes is the Electronic Codebook (ECB) mode (named after conventional physical codebooks[10]). The message is divided into blocks, and each block is encrypted separately.

The disadvantage of this method is a lack of diffusion. Because ECB encrypts identical plaintext blocks into identical ciphertext blocks, it does not hide data patterns well. In some senses, it doesn't provide serious message confidentiality, and it is not recommended for use in cryptographic protocols at all.

Cipher Block Chaining (CBC)

In CBC mode, each block of plaintext is XORed with the previous ciphertext block before being encrypted. This way, each ciphertext block depends on all plaintext blocks processed up to that point. To make each message unique, an initialization vector must be used in the first block.

CBC has been the most commonly used mode of operation. Its main drawbacks are that encryption is sequential. and that the message must be padded to a multiple of the cipher block size. Note that a one-bit change in a plaintext or initialization vector (IV) affects all following ciphertext blocks.

Cipher Feedback (CFB)

The Cipher Feedback (CFB) mode, a close relative of CBC, makes a block cipher into a self-synchronizing stream cipher. Operation is very similar; in particular, CFB decryption is almost identical to CBC encryption performed in reverse:

ythy commented 6 years ago

Block cipher modes for symmetric-key encryption algorithms require plain text input that is a multiple of the block size, so messages may have to be padded to bring them to this length. There is currently a shift to use streaming mode of operation instead of block mode of operation. Streaming modes of operation can encrypt and decrypt messages of any size and therefore do not require padding. reference