4 Symmetric encryption

 

This chapter covers

  • Ensuring confidentiality with encryption
  • Introducing the cryptography package
  • Choosing a symmetric encryption algorithm
  • Rotating encryption keys

In this chapter, I’ll introduce you to the cryptography package. You’ll learn how to use the encryption API of this package to ensure confidentiality. Keyed hashing and data authentication, from previous chapters, will make an appearance. Along the way, you’ll learn about key rotation. Finally, I’ll show you how to distinguish between safe and unsafe symmetric block ciphers.

4.1 What is encryption?

Encryption begins with plaintext. Plaintext is information that is readily comprehensible. The Gettysburg Address, an image of a cat, and a Python package are examples of potential plaintext. Encryption is the obfuscation of plaintext with the purpose of hiding information from unauthorized parties. The obfuscated output of encryption is known as ciphertext.

The inverse of encryption, the transformation of ciphertext back to plaintext, is known as decryption. An algorithm for encrypting and decrypting data is called a cipher. Every cipher requires a key. A key is intended to be a secret among parties who are authorized to access encrypted information (figure 4.1).

Figure 4.1 Plaintext is the human-readable input to encryption and the output of decryption; ciphertext is the machine-readable output of encryption and the input to decryption.
CH04_F01_Byrne

4.1.1 Package management

4.2 The cryptography package

4.2.1 Hazardous materials layer

4.2.2 Recipes layer

4.2.3 Key rotation

4.3 Symmetric encryption

4.3.1 Block ciphers

sitemap