Major Assignment: Cryptographic Tools, Block and Stream
Ciphers, and their Algorithms
Submitted By
M. Sameer Ali (12670)
BS Computer Science
Information Security
Section: C
Submitted To
Mr. Sardar Sadiq Ali
Department of Computer Sciences
City University of Science and Information Technology
Peshawar – Pakistan
Table of Contents
Table of Contents ........................................................................................... Error! Bookmark not defined.
Introduction to Cryptography ....................................................................................................................... 1
Block Ciphers ................................................................................................................................................. 1
How Block Ciphers Work........................................................................................................................... 2
Popular Block Cipher Algorithms .............................................................................................................. 2
1. Data Encryption Standard (DES) ....................................................................................................... 2
2. Advanced Encryption Standard (AES) ............................................................................................... 3
3. Triple DES (3DES)............................................................................................................................... 3
Stream Ciphers .............................................................................................................................................. 4
How Stream Ciphers Work........................................................................................................................ 4
Popular Stream Cipher Algorithms ....................................................................................................... 4
1. RC4 .................................................................................................................................................... 4
2. ChaCha .............................................................................................................................................. 5
Block Ciphers vs. Stream Ciphers .................................................................................................................. 5
Conclusion ..................................................................................................................................................... 6
Introduction to Cryptography
Cryptography is the practice of securing information by transforming it into an unreadable format
to protect it from unauthorized access. In the digital age, cryptography plays a central role in
protecting data integrity, confidentiality, and authenticity across various applications such as
online banking, secure communication, and e-commerce. Without cryptography, sensitive
information like personal messages, credit card details, and corporate data would be vulnerable to
interception, manipulation, and fraud.
Cryptographic techniques can be categorized into two main types: symmetric-key cryptography
and asymmetric-key cryptography. Symmetric-key cryptography uses the same key for both
encryption and decryption, while asymmetric-key cryptography uses a pair of keys: a public key
for encryption and a private key for decryption. This classification forms the basis for two primary
classes of encryption algorithms: block ciphers and stream ciphers. These encryption methods
operate differently and have distinct advantages, use cases, and security guarantees.
In symmetric-key cryptography, data can be encrypted using either a block cipher or a stream
cipher, depending on the type of application. Both techniques aim to convert plaintext (readable
data) into ciphertext (unreadable data), but they do so in different ways, each suited to different
needs. Understanding these differences is essential to selecting the right cryptographic algorithm
for specific tasks.
Block Ciphers
Block ciphers are a widely used type of symmetric encryption algorithm that encrypts data in fixed-
size blocks, typically 64 or 128 bits at a time. The block cipher operates by taking a block of
plaintext and transforming it into ciphertext using a fixed-length key through a series of rounds.
Each round applies various transformations, such as substitution, permutation, and key mixing,
which help to obscure the relationship between the plaintext and the ciphertext, making it difficult
to reverse the process without the key.
1
How Block Ciphers Work
Block ciphers operate by breaking the plaintext into fixed-size blocks and applying a series of
mathematical operations to each block individually. The plaintext is divided into 64-bit or 128-bit
segments, and each segment is encrypted with a secret key. If the length of the plaintext is not a
multiple of the block size, padding is applied to ensure that the final block is of the correct size.
After encryption, each block of plaintext is transformed into a corresponding block of ciphertext.
The encryption process involves several rounds of operations, which typically include
substitution, permutation, key mixing, and sometimes mixing of ciphertext blocks. These
operations create diffusion (spreading the plaintext information throughout the ciphertext) and
confusion (making the relationship between the ciphertext and the key obscure). By applying
multiple rounds of these operations, block ciphers create a highly secure encryption scheme that
is difficult to crack using brute-force or other cryptographic attacks.
Popular Block Cipher Algorithms
1. Data Encryption Standard (DES)
The Data Encryption Standard (DES was one of the earliest symmetric-key block ciphers,
developed by IBM in the 1970s. DES became the U.S. federal standard for encryption and was
widely adopted for secure data encryption. DES operates on 64-bit blocks and uses a 56-bit key to
encrypt the data. It performs 16 rounds of encryption, each round applying a complex mixture of
substitution (through S-boxes) and permutation (through P-boxes) operations. The key used in
DES is relatively short, only 56 bits long, which made it increasingly vulnerable to brute-force
attacks as computing power grew.
Despite its historical significance, DES is no longer considered secure for modern applications due
to the vulnerability posed by its small key size. Brute-force attacks on DES can be executed within
a matter of hours with modern computational resources. As a result, DES has been largely replaced
by stronger block ciphers like AES.
2
2. Advanced Encryption Standard (AES)
The Advanced Encryption Standard (AES) was introduced as a successor to DES and has
become the most widely used block cipher in modern cryptographic applications. AES was
selected by NIST (National Institute of Standards and Technology) in 2001 after a public
competition aimed at selecting a new encryption standard. AES supports three key sizes: 128, 192,
and 256 bits, and operates on 128-bit blocks of data.
AES uses a series of rounds to transform the plaintext into ciphertext. The number of rounds
depends on the key size: 10 rounds for a 128-bit key, 12 rounds for a 192-bit key, and 14 rounds
for a 256-bit key. Each round involves operations like SubBytes, ShiftRows, MixColumns, and
AddRoundKey which introduce both confusion and diffusion into the encryption process. The
AES algorithm is highly efficient, secure, and widely used in various applications, including
securing internet communications (SSL/TLS), file encryption, disk encryption, and VPNs.
3. Triple DES (3DES)
The Triple DES (3DES) algorithm was introduced as an enhancement to the original DES to
address its vulnerabilities. While DES uses a single 56-bit key, 3DES applies the DES algorithm
three times in succession with either two or three different keys. The key length for 3DES is either
112 bits (using two keys) or 168 bits (using three keys). This enhancement significantly increases
the key size and, therefore, the security of the encryption.
Despite its improved security over DES, 3DES is considered slower and less efficient than AES,
which is why it is being phased out in many modern cryptographic systems. Nevertheless, 3DES
is still used in certain legacy systems and applications where backward compatibility with older
systems is required.
3
Stream Ciphers
Unlike block ciphers, which encrypt data in fixed-size blocks, stream ciphers encrypt data one
bit or byte at a time. This method is more efficient for real-time communication and scenarios
where the amount of data to be encrypted is not known in advance or can vary in size. Stream
ciphers are often used in protocols that require low-latency encryption, such as voice over IP
(VoIP), video streaming, and secure wireless communications.
How Stream Ciphers Work
Stream ciphers encrypt data by generating a keystream, which is a sequence of bits that is
combined with the plaintext to produce ciphertext. The keystream is generated based on a secret
key and sometimes an additional value called a nonce (a number used once). The keystream is
typically generated using a pseudorandom number generator (PRNG), which produces a sequence
of bits that appears random but is deterministic based on the initial key and nonce.
The keystream is then XORed with the plaintext data, and the result is the ciphertext. XORing the
keystream with the plaintext ensures that the ciphertext is different from the plaintext in an
unpredictable manner, providing confidentiality. The decryption process involves XORing the
ciphertext with the same keystream to recover the original plaintext.
Stream ciphers are known for their efficiency, as they allow encryption to be performed on-the-fly
without requiring the entire message to be buffered in memory. This makes stream ciphers ideal
for applications such as secure messaging, streaming video, and network protocols where
performance and low latency are critical.
Popular Stream Cipher Algorithms
1. RC4
RC4 (Rivest Cipher 4) is one of the most widely used stream ciphers, initially designed by Ron
Rivest in 1987. It gained popularity due to its simplicity and high speed, and was widely adopted
in protocols like SSL/TLS (for securing web traffic) and WEP (for wireless encryption). RC4
4
operates by generating a keystream from a secret key, which is then XORed with the plaintext data
to produce ciphertext.
Despite its popularity, RC4 has significant vulnerabilities. The key scheduling algorithm (KSA)
and the pseudorandom generation algorithm (PRGA) exhibit weaknesses that can lead to statistical
biases in the keystream. These weaknesses have been exploited in several cryptographic attacks,
making RC4 unsuitable for modern security applications. As a result, RC4 has been deprecated in
favor of more secure algorithms like ChaCha.
2. ChaCha
ChaCha is a family of stream ciphers developed by Daniel J. Bernstein as an improved variant of
the Salsa20 stream cipher. ChaCha is designed to provide a more secure and efficient alternative
to RC4 and is widely used in modern cryptographic protocols. ChaCha uses a 256-bit key and a
64-bit nonce to generate a keystream. The encryption process involves a series of rotations and
additions to produce a pseudorandom keystream that is XORed with the plaintext.
ChaCha has gained popularity due to its security and performance advantages over RC4,
particularly in environments where security is critical, such as in VPNs, SSL/TLS, and mobile
applications. The cipher is also resistant to certain attacks that affect RC4, making it suitable for
modern cryptographic applications.
Block Ciphers vs. Stream Ciphers
The main distinction between block ciphers and stream ciphers is how they handle the data. Block
ciphers encrypt data in fixed-size blocks (e.g., 64 bits or 128 bits), which makes them ideal for
applications like file encryption, where data can be divided into chunks. Stream ciphers, on the
other hand, encrypt data bit-by-bit or byte-by-byte, making them more suited to real-time
communication or applications where data size is variable or unknown, such as streaming media
or online chats.
Block ciphers generally provide stronger security due to their more complex structure and multiple
rounds
5
of encryption, while stream ciphers are often faster and more efficient, especially for scenarios
that require continuous encryption with low overhead. The trade-off between the two depends on
the specific needs of the application: block ciphers are preferred when security is the top priority,
while stream ciphers are ideal when speed and performance are essential.
Conclusion
Both block ciphers and stream ciphers are fundamental to modern cryptographic systems, each offering
distinct advantages depending on the use case. Block ciphers, such as AES, provide robust security and
are well-suited for applications requiring high levels of data confidentiality, such as file encryption and
secure communication protocols. Stream ciphers, like ChaCha, offer the advantage of efficiency, making
them ideal for real-time encryption of data streams in applications like video conferencing and VoIP.
Understanding the characteristics, mechanisms, and algorithms of both block and stream ciphers is essential
for choosing the right cryptographic tool for different security requirements. As cyber threats continue to
evolve, so too will the development of these encryption techniques, ensuring the continued protection of
sensitive data in an increasingly connected world.