Javatpoint Logo
Javatpoint Logo

Difference Between Block Cipher and Stream Cipher

Block cipher and stream cipher are members of the family of symmetric key ciphers, essentially encryption techniques used for directly transforming the plaintext into ciphertext.

In this article, we will discuss the characteristics of block ciphers and stream ciphers and how they differ from one another.

What is Block Cipher?

Difference Between Block Cipher and Stream Cipher

A block cipher is a symmetric cryptographic technique which we used to encrypt a fixed-size data block using a shared, secret key. During encryption, we used plaintext and ciphertext is the resultant encrypted text. It uses the same key to encrypt both the plaintext, and the ciphertext.

A block cipher processes the data blocks of fixed size. Typically, a message's size exceeds a block's size. As a result, the lengthy message is broken up into a number of sequential message blocks, and the cipher operates on these blocks one at a time.

With the help of the shared secret key, a block cipher encrypts and decrypts its input one block rather than one bit at a time. Since the block's size is fixed, padding is not necessary. It is a symmetric algorithm. During encryption, it converts text input into cyphertext using the shared key. It uses the same key during decryption to change the cyphertext back to the original plaintext. The length of the output and input are identical.

  • Popular variations of the block cipher algorithm include the Data Encryption Standard (DES), TripleDES, and the Advanced Encryption Standard (AES).
  • The stream cipher uses a shared key and operates on its input one bit at a time, which is the block cipher's counterpart.
  • Alternative to the block cipher algorithm includes public-key cryptography and asymmetric cryptography. This algorithm uses the public key to encrypt plaintext and a private key to decrypt the ciphertext.

There are various modes of operation of a block cipher:

  • Electronic Code Book (ECB) Mode
  • Cipher Block Chaining (CBC) Mode
  • Cipher Feedback (CFB) Mode
  • Output Feedback (OCB) Mode
  • Counter (CTR) Mode

These modes serve as a block cipher's general procedures principles.

1. Electronic Codebook Mode

Electronically code message in plaintext form is dine in ECB mode. It is the most straightforward block cipher operating mode. It does not introduce any randomness to the key stream, and it is the only mode we can use to encrypt a single-bit stream. Using the cipher's key and substitution alphabet, each plaintext symbol, such as a character from the plaintext alphabet, is transformed into a ciphertext symbol. Each block of plaintext is encrypted separately from every other block. Only 8 bytes of the key are used when the plaintext block is only 8 bytes long, and all 100 bytes of the key are utilised when the plaintext block is 100 bytes long.

2. Cipher Block Chaining Mode (CBC)

When using CBC mode to encrypt data, each block of plaintext is combined with the ciphertext that came before it. A ciphertext generated by the symmetric algorithm depends on all plaintext block processed in the data stream before it. This is done to ensure that every block of the ciphertext depends on every other block that came before it. Before using the cipher algorithm to encrypt the data, each block of plaintext is XORed (exclusive OR) with the block of ciphertext that came before it. Numerous security applications used CBC mode. For example, Secure Sockets Layer/Transport Layer Security uses CBC mode in order to encrypt data which is transferred over the internet.

3. Ciphertext Feedback Mode (CFB)

It is occasionally important to quickly encrypt and send plaintext values, one at a time, as opposed to CBC mode, which encrypts a predetermined number of bits of plaintext at a time. CFB also uses an IV, similar to CBC. A block cipher is a part of the random number generator used by CFB. In CFB mode, the previous ciphertext block is encrypted, and the output is XORed with the current plaintext block to create the current ciphertext block.

4. Output Feedback Mode (OFB)

In certain ways, CBC and OFB modes are comparable and can be used with any block cipher. It uses a feedback mechanism; however, in OFB mode, the preceding block of ciphertext is XORed with the plaintext after encryption rather than prior to encryption.

5. Counter Mode (CTR)

CTR mode uses a block chaining mode of encryption as a building block. The process of encrypting data is performed by XORing the plaintext with a series of pseudorandom values that are each created from the ciphertext using a feedback function; data is encrypted. A series of XORs between blocks of plaintext and corresponding blocks of ciphertext can be used to represent the CTR encryption process.

Examples of Block Ciphers

The majority of contemporary cipher suites are based on block ciphers. Several encryption standard protocols that utilise block ciphers are:

1. Data Encryption Standard (DES)

Initially, sensitive, private information was protected using a 56-bit symmetric key algorithm. DES was later discontinued because of its short length and other security issues, although it is still regarded as a pioneer encryption standard.

2. Advanced Encryption Standard (AES)

It is a popular block cipher which encrypts data in blocks of 128 bits using 128, 192, and 256-bit symmetric keys. The underlying block cipher uses substitution-permutation and transportation techniques to produce ciphertext by shuffling and replacing input data in a sequence of linked calculations. AES is a widely encryption standard since cryptanalysis efforts against its algorithms have been ineffective.

3. Twofish

Twofish is an encryption standard that uses a Feistel network, a complex key schedule, and substitution techniques to separate the key and ciphertext. Using keys that can range in size from 128 to 256 bits, the standard encrypts plaintext data in blocks of 128 bits.

Block ciphers are also used by other encryption schemes such as 3DES, Serpent, and Blowfish.

What is Stream Cipher?

Difference Between Block Cipher and Stream Cipher

A stream cipher uses time-varying changes on plaintext data to encrypt a continuous string of binary numbers. As a result, this method of encryption works bit-by-bit, utilising keystreams to generate ciphertext for arbitrary lengths of plain text messages. The cipher combines a key (128/256 bits) and a nonce digit (64-128 bits) in order to generate the keystream - a pseudorandom number XORed with the plaintext to generate the ciphertext. The keystream must be different for each encryption iteration even though the key and nonce can be reused to maintain security. In order to build the keystream, stream encryption ciphers generate a unique nonce (a number used only once utilising feedback shift registers.

Since a mistake in the translation of one bit often does not affect the entire plaintext block, stream cipher encryption algorithms are less likely to cause system-wide errors to spread. Additionally, stream encryption is linear and continuous, making it easier and quicker to deploy. However, stream ciphers do not have diffusion because each digit of the plaintext is mapped to one ciphertext output. Furthermore, they don't check for validity, which leaves them open to insertions. If hackers defeat the encryption algorithm, they are able to add to or change the encrypted message without being noticed. Stream ciphers are typically used to encrypt data in an application where the volume of plain text cannot be predicted and in low latency use-cases.

In other words, a stream cipher is a type of encryption that uses plain text numbers and a stream of pseudorandom cipher digits. Each binary digit receives one bit at a time of this pseudorandom encryption digit stream. This encryption technique uses an infinite number of pseudorandom cipher digits for each key.

State cipher is another name for a stream cipher. The term "state cipher" refers to a system where the encryption of each number is dependent on the cipher's current state.

Types of Stream Ciphers

There are two types of Stream Ciphers:

1. Synchronous Stream Ciphers

In a synchronous stream cipher, the keystream block is created independently of the previous ciphertext and plaintext messages. The most popular stream cipher modes produce a string of bits using pseudorandom number generators and combine it with the key to create the keystream, which is then XORed with the plaintext to produce the ciphertext.

2. Self-Synchronizing/Asynchronous stream Ciphers

The previous ciphertext block's fixed size (N-bits) and symmetric key are used to generate the keystream block via a self-synchronizing stream cipher, also known as ciphertext autokey. Asynchronous stream cipher can recognize active attacks by altering the ciphertext, which changes the information in the subsequent keystream. Due to the fact that a single-digit error can only affect a maximum of N bits, these ciphers also have restricted error propagation.

Example of Stream Ciphers

The following are examples of stream ciphers:

1. River Cipher (RC4)

A quick and easy encryption algorithm called RC4/ARC4/ARCFOUR was created in 1987 to accomplish byte-by-byte encryption utilising 64- or 128-bit length keys. Transport Layer Security, secure Sockets Layer, and the IEEE 802.11 WLAN standard all use extensively RC4. The widely used encryption method is available in a number of variations, including SPRITZ, RC4A, and RC4A+.

2. Salsa20

Salsa20 is a powerful, up-to-date encryption cipher that creates the encryption keystream using an expansion function. Salsa20 also relies on a core function which uses add-rotate-XOR (ARX) operations to map the key, a nonce digit, and constant vectors retrieved from the expansion function to the keystream.

3. Software-Optimized Encryption Algorithm (SEAL)

An additive binary stream cipher called SEAL is designed for systems with 32-bit CPUs and enough RAM. The encryption standard depends on a pseudorandom family that maps a 32-bit string to any length string using a length-increasing function and a 160-bit key.

PANAMA, Scream, Rabbit, HC-256, and Grain are a few other examples of stream ciphers.

Difference Between Block Cipher and Stream Cipher

Difference Between Block Cipher and Stream Cipher
Parameters Block Cipher Stream Cipher
Definition Block Cipher is the kind of encryption that converts plaintext by taking each block individually. Stream cipher is the kind of encryption that converts plaintext by taking one byte of the plaintext at a time.
Principle It uses both diffusion and confusion principles for the conversion (used later in encryption). Only the confusion principle is used by Stream Cipher for the conversion.
Decryption In Block cipher, reverse encryption or decryption is more difficult than stream cipher since more bits are combined to be encrypted in this scenario. In a stream cipher, XOR is used for encryption that can quickly converted back to plain text.
Implementation Feistel Cipher is the most popular block cipher implementation. Vernam Cipher is the main implementation of Stream Cipher.
Implementation Feistel Cipher is the most popular block cipher implementation. Vernam Cipher is the main implementation of Stream Cipher.
Conversion of Bits Since a block cipher converts blocks at once, it converts more significant bits than a stream cipher, which can convert 64 bits or more. However, in stream cipher, only 8 bits can be transformed simultaneously.
Reversibility It is difficult to reverse encrypted text. It uses XOR encryption, which is easily reversed to the plain text.
Confusion and Diffusion Block Cipher uses both confusion and diffusion. Stream cipher relies on confusion only.
Algorithm modes used ECB (Electronic Code Book) CBC (Cipher Block Chaining) CFB (Cipher Feedback)
OFB (Output Feedback)
Complexity Simple design Complex comparatively
No of bits used 64 Bits or more 8 Bits

Advantages of Stream Cipher Over Block Cipher

The following are the advantages of stream cipher over block cipher:

  • Stream ciphers are faster than block ciphers and work well for both small and large chunks of data.
  • Unlike block ciphers, which need a significant amount of memory because they operate on large chinks of data, stream ciphers only operate on bits at a time.
  • Stream cipher bytes are encrypted separately from other data chunks, whereas block cipher encrypts an entire block at once.
  • In general, Stream ciphers operate best in situations where the amount of data is either continuous or unknown, such as network streams, whereas block cipher function better when the amount of duration of the data is known, such as in files, data fields, or response protocols.

Key Differences Between Block Cipher and Stream Cipher

  • When using a block cipher, each block of text is encrypted separately. Decrypt the text similarly by selecting one block at a time. The stream cipher approach, in contrast, encrypts and decrypts the text one byte at a time.
  • In block cipher, confusion and diffusion, both are used but in stream cipher only relies on confusion.
  • In Block Cipher, the same key is used for encryption but in Stream Cipher, a different key is used for each byte.
  • The ECB (Electronic Code Book) and CBC (Cipher Block Chaining) algorithm modes are used in the block cipher. Contrarily, the CFB (Cipher Feedback) and OFB (Output Feedback) algorithm modes are used in the stream cipher.
  • In the Block cipher, the typical block size is between 64 and 128 bits. In contrast, the stream cipher converts 1 byte (8 bits) at a time.

Next TopicDifference between





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA