0% found this document useful (0 votes)
0 views7 pages

Symmetric Key Encryption

The document discusses symmetric key encryption, emphasizing the principles of confusion and diffusion as proposed by Claude Shannon. It outlines key symmetric algorithms like AES, ChaCha20, and 3DES, and differentiates between block ciphers and stream ciphers, detailing their operations and use cases. Additionally, it covers modes of operation for symmetric encryption, highlighting the importance of the Initialization Vector (IV) and the security implications of reusing keys or IVs.

Uploaded by

yepseuchristian
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views7 pages

Symmetric Key Encryption

The document discusses symmetric key encryption, emphasizing the principles of confusion and diffusion as proposed by Claude Shannon. It outlines key symmetric algorithms like AES, ChaCha20, and 3DES, and differentiates between block ciphers and stream ciphers, detailing their operations and use cases. Additionally, it covers modes of operation for symmetric encryption, highlighting the importance of the Initialization Vector (IV) and the security implications of reusing keys or IVs.

Uploaded by

yepseuchristian
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Symmetric Key Encryption Principles and Algorithms

As we defined in Week 1, symmetric encryption uses a single, shared secret key for both encryption and
decryption. Let's formalize this process and look at the most important algorithms in this family.

1.1 The Core Principle: Confusion and Diffusion

In the 1940s, Claude Shannon, the father of information theory, suggested that good ciphers should be
based on two key principles to thwart statistical attacks:

1. Confusion: This aims to make the relationship between the ciphertext and the symmetric key as
complex and involved as possible. If an attacker changes one bit of the key, a good cipher should produce
a dramatically different ciphertext. This makes it hard to find patterns linking the key to the output.
Substitution (replacing parts of the data with other parts) is a primary method for creating confusion.

2. Diffusion: This aims to dissipate the statistical structure of the plaintext over the bulk of the
ciphertext. If an attacker changes a single character of the plaintext, many characters (ideally, half) of
the ciphertext should change. This hides the statistical relationships between characters in the plaintext.
Permutation (rearranging the order of data) is a primary method for creating diffusion.

Modern symmetric algorithms, like AES, achieve this through multiple rounds of substitution and
permutation.

1.2 Key Symmetric Algorithms

While many symmetric algorithms have been developed over the years, a few have become industry
standards.

- AES (Advanced Encryption Standard):

- Status: The current global standard for symmetric encryption. It is approved by the U.S. government
for securing top-secret information.

- How it works: It is a block cipher (which we will define in the next section) that uses a fixed block
size of 128 bits. It supports key sizes of 128, 192, or 256 bits (AES-128, AES-192, AES-256). The
number of rounds depends on the key size (10 rounds for 128-bit, 12 for 192-bit, 14 for 256-bit).

- Use Case: Used everywhere: Wi-Fi (WPA2/WPA3), HTTPS, full-disk encryption (BitLocker,
FileVault), file compression tools (WinZip, 7-Zip), and many more.
- ChaCha20

- Status: A modern stream cipher (defined in the next section) designed by Daniel J. Bernstein. It is
gaining popularity as a faster and more secure alternative to older ciphers, especially on devices without
dedicated AES hardware acceleration (like many mobile phones).

- How it works: It's a stream cipher that is incredibly fast and resistant to many side-channel attacks
(attacks based on information leaked by the physical implementation, like power consumption or
timing).

- Use Case: Used by Google for TLS connections in the Chrome browser on mobile devices, and in
the WireGuard VPN protocol.

- 3DES (Triple Data Encryption Standard):

- Status: A legacy algorithm, now considered deprecated and insecure for most new applications.

- How it works: It applies the older DES algorithm three times to each data block. While this
improved security over the original DES (which had a too-small 56-bit key), it is still relatively slow
and has its own theoretical vulnerabilities.

- Use Case: You might still encounter it in older financial systems (like some ATMs), but it is being
actively phased out.

Block Ciphers and Stream Ciphers


This is a fundamental distinction in symmetric encryption. The primary difference lies in *how* they
process the plaintext.

2.1 Block Ciphers

- Definition: A block cipher encrypts data in fixed-size chunks called blocks. If the plaintext is longer
than the block size, it is broken up into multiple blocks, and each block is encrypted separately (often
with some linking between them, as we'll see in Section 3).

- Common Block Sizes: 64 bits (older algorithms like DES) or 128 bits (modern algorithms like AES).

- How it Works (Conceptual): Think of a block cipher as a magic box that takes two inputs—a block
of plaintext (e.g., 128 bits) and a secret key—and produces a single block of ciphertext (also 128 bits).
The transformation is the same for every block when using the same key.
- Padding: What if your data isn't a perfect multiple of the block size (e.g., you have 150 bits of data
with a 128-bit block cipher)? The last block will be incomplete. You must add extra data to fill it up to
the block size. This is called padding. The padding must be added in a way that the receiver can
unambiguously remove it after decryption.

- Examples: AES, 3DES, Blowfish (an older cipher).


what is blowfish

2.2 Stream Ciphers

- Definition: A stream cipher encrypts data one bit or one byte at a time. It does not operate on fixed
blocks. It generates a pseudo-random stream of bits, called the keystream, which is then combined with
the plaintext, typically using the XOR (exclusive OR) operation.

- How it Works:

1. The cipher takes the secret key and generates a long, unpredictable sequence of bits—the
keystream. This keystream must be unique for each encryption session.

2. Encryption: The plaintext is combined with the keystream using XOR. `Ciphertext = Plaintext
XOR Keystream`

3. Decryption: The receiver, using the same key, generates the identical keystream and XORs it with
the ciphertext. `Plaintext = Ciphertext XOR Keystream` (Because XOR is reversible).

- Critical Rule - Never Reuse a Keystream: If you ever use the same keystream to encrypt two different
messages, an attacker can XOR the two ciphertexts together and recover the combination of the two
plaintexts, which can often be trivially separated. This is a catastrophic failure.

- Examples: ChaCha20, Salsa20, and the now-broken RC4.

- Analogy: Imagine a spy's one-time pad. The pad contains a long, truly random list of numbers (the
keystream). To send a message, the spy adds each letter of the message to the next number on the pad.
The receiver, having an identical copy of the pad, subtracts the numbers to recover the message. A stream
cipher is like a one-time pad, but the keystream is generated by an algorithm (making it pseudo-random,
not truly random).
2.3 Comparison: Block vs. Stream Ciphers

Feature Block cipher Stream cipher


Operation Encrypts fixed-size blocks (e.g., 128 bits). Encrypts bits/bytes one at a
time
Speed Generally, very fast, often
Generally fast, but can be slower than stream
faster than block ciphers.
ciphers for small amounts of data.

Implementation Simpler to implement in


More complex due to padding and modes of
hardware.
operation.
Error An error in one bit of
An error in one block of ciphertext may affect
Propagation ciphertext only affects that one
the decryption of that block and potentially the
next (depending on the mode). bit of plaintext.
Use case Network streams (like TLS
File encryption, disk encryption, database
1.3), real-time audio/video
encryption.
encryption.

Modes of Operation for Symmetric Encryption


A block cipher on its own, like AES, is a basic building block. If you simply split a message into 128-
bit blocks and encrypt each one separately with the same key, you create a mode called Electronic
Codebook (ECB) mode. This is highly insecure because identical plaintext blocks will produce identical
ciphertext blocks, revealing patterns in the data (like a silhouette of an image).

To solve this problem and add security features, we use modes of operation. These modes dictate how
the encryption of one block relates to the next. Here are the most important ones:

3.1 Common Modes of Operation

- Cipher Block Chaining (CBC) Mode

- How it works: Before a plaintext block is encrypted, it is XORed with the previous ciphertext block.
This chains the blocks together.
- Initialization Vector (IV): For the very first block, there is no previous ciphertext, so a random,
unique block of data called an Initialization Vector (IV) is used. The IV does not need to be secret, but
it must be random and unique for every encryption session.

- Effect: This ensures that even if you encrypt the same message twice with the same key, the
ciphertext will be completely different (because the IVs are different).

- Use Case: Was the most common mode for many years. Still widely used in file encryption and
legacy systems.

- Counter (CTR) Mode

- How it works: This mode effectively turns a block cipher into a stream cipher. It does not encrypt
the plaintext directly. Instead, it encrypts a "counter" value that increments for each block. The encrypted
counter becomes the keystream, which is then XORed with the plaintext.

- IV: A nonce (number used once) is combined with the counter value to ensure uniqueness.

- Advantages: It is very fast, can be parallelized (you can encrypt multiple blocks at the same time),
and does not require padding.

- Use Case: Widely used in modern systems, including disk encryption and network protocols.

- Galois/Counter Mode (GCM)

- How it works: GCM is an authenticated encryption mode. It combines the CTR mode for
confidentiality with a powerful integrity check called Galois Message Authentication Code (GMAC).

- The "Two-in-One" Advantage: GCM provides both confidentiality and integrity/authentication in


a single, efficient operation. When you decrypt data encrypted with GCM, you can be sure it hasn't been
tampered with.

- Use Case: GCM is the gold standard for modern network security. It is the preferred mode for TLS
1.2 and TLS 1.3 (AES-GCM) and for the ChaCha20-Poly1305 cipher suite (which is ChaCha20 with a
similar authenticated mode called Poly1305).
3.2 Visualizing Modes of Operation

Imagine you have a sentence: "THISISASECRETMESSAGE".

- ECB Mode (Insecure): You cut the sentence into equal-length chunks. "THISIS" + "ASECRE" +
"TMESSA" + "GE". If "THISIS" appears again later, its encrypted version will look the same. Patterns
are visible.

- CBC Mode: Before encrypting "ASECRE", you mix it with the encrypted result of "THISIS". Now
every chunk's encryption depends on all previous chunks, eliminating patterns.

3.3 The Critical Role of the Initialization Vector (IV)

A common mistake is to treat the IV as a secondary key or to reuse it.

- An IV is NOT a key, it does not need to be secret.

- An IV MUST be random and unique for every encryption operation with the same key. Reusing an IV
with the same key in many modes (especially CTR and GCM) can be catastrophic, leading to a total
breakdown of security, just like reusing a keystream in a stream cipher.

Key Takeaways
- Good symmetric ciphers rely on confusion (substitution) and diffusion (permutation) to hide statistical
patterns.

- AES is the current, trusted standard for symmetric encryption. ChaCha20 is a modern, high-
performance alternative, especially on mobile devices.

- Block ciphers (like AES) encrypt fixed-size blocks and often require padding. Stream ciphers (like
ChaCha20) encrypt data bit-by-bit by XORing it with a generated keystream. Never reuse a keystream.

- A block cipher by itself (ECB mode) is insecure. Modes of operation like CBC and CTR are used to
securely encrypt messages longer than one block.

- GCM is a highly important modern mode because it provides both confidentiality and integrity
(authenticated encryption).

- The Initialization Vector (IV) must be random and unique for each encryption session. Reusing an IV
is a critical security flaw.
### Review Questions

1. Explain the difference between a block cipher and a stream cipher. Give a real-world example of
where you would likely use each.

2. Why is ECB mode considered insecure? Use the example of encrypting a simple black-and-white
image to explain your answer.

3. What is the purpose of an Initialization Vector (IV) in CBC mode? If you accidentally used the same
IV to encrypt two different messages with the same key, what might an attacker be able to do?

4. You are designing a new secure messaging app. Why would choosing AES in GCM mode be a better
choice than choosing AES in CBC mode? (Hint: Think about what GCM provides beyond
confidentiality).

5. Common Mistake: A student implements encryption and, to simplify the code, decides to use a static,
hardcoded IV. Explain to the student why this is a dangerous practice, especially when using a mode
like CTR or GCM.

You might also like