07.07.2023 Views

Implementing-cryptography-using-python

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 5 ■ Stream Ciphers and Block Ciphers 159

Plaintext Plaintext Plaintext

Key

block cipher

encryption

Key

block cipher

encryption

Key

block cipher

encryption

Ciphertext Ciphertext Ciphertext

Figure 5.5: ECB mode encryption

Ciphertext Ciphertext Ciphertext

Key

block cipher

decryption

Key

block cipher

decryption

Key

block cipher

decryption

Plaintext Plaintext Plaintext

Figure 5.6: ECB mode decryption

In Figure 5.6, you will see that ciphertext enters the block cipher decryption

mode, which accepts a key and produces the decryption.

CBC Mode

The CBC mode, formally named Cipher Block Chaining, was created in 1976

by Ehrsam, Meyer, Smith, and Tuchman. When using CBC mode, each block

of plaintext is XOR’d with the previous ciphertext block. This ensures that each

ciphertext block depends on all plaintext blocks processed up to that point. As

shown in Figure 5.4, the IV is used on the initial block and then the produced

ciphertext is used to encrypt the plaintext of the next block. Figure 5.7 shows

the inverse operation.

CBC is the dominant mode of operation. Its major drawback is that encryption

must be performed sequentially as opposed to encrypting in parallel. A

second drawback is that the message must be padded to a multiple of the cipher

block size.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!