The Wayback Machine - https://web.archive.org/web/20241125080408/https://www.geeksforgeeks.org/block-cipher-modes-of-operation/
Open In App

Block Cipher modes of Operation

Last Updated : 09 May, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Encryption algorithms are divided into two categories based on the input type, as a block cipher and stream cipher. Block cipher is an encryption algorithm that takes a fixed size of input say b bits and produces a ciphertext of b bits again. If the input is larger than b bits it can be divided further. For different applications and uses, there are several modes of operations for a block cipher. 

Electronic Code Book (ECB) – 
Electronic code book is the easiest block cipher mode of functioning. It is easier because of direct encryption of each block of input plaintext and output is in form of blocks of encrypted ciphertext. Generally, if a message is larger than b bits in size, it can be broken down into a bunch of blocks and the procedure is repeated. 

Procedure of ECB is illustrated below: 

Advantages of using ECB – 

  • Parallel encryption of blocks of bits is possible, thus it is a faster way of encryption.
  • Simple way of the block cipher.

Disadvantages of using ECB –  

  • Prone to cryptanalysis since there is a direct relationship between plaintext and ciphertext. 

Cipher Block Chaining – 
Cipher block chaining or CBC is an advancement made on ECB since ECB compromises some security requirements. In CBC, the previous cipher block is given as input to the next encryption algorithm after XOR with the original plaintext block. In a nutshell here, a cipher block is produced by encrypting an XOR output of the previous cipher block and present plaintext block. 

The process is illustrated here: 

Advantages of CBC – 

  • CBC works well for input greater than b bits.
  • CBC is a good authentication mechanism.
  • Better resistive nature towards cryptanalysis than ECB.

Disadvantages of CBC –  

  • Parallel encryption is not possible since every encryption requires a previous cipher. 

Cipher Feedback Mode (CFB) – 
In this mode the cipher is given as feedback to the next block of encryption with some new specifications: first, an initial vector IV is used for first encryption and output bits are divided as a set of s and b-s bits.The left-hand side s bits are selected along with plaintext bits to which an XOR operation is applied. The result is given as input to a shift register having b-s bits to lhs,s bits to rhs and the process continues. The encryption and decryption process for the same is shown below, both of them use encryption algorithms. 

Advantages of CFB – 

  • Since, there is some data loss due to the use of shift register, thus it is difficult for applying cryptanalysis. 

Disadvantages of using CFB –  

  • The drawbacks of CFB are the same as those of CBC mode. Both block losses and concurrent encryption of several blocks are not supported by the encryption. Decryption, however, is parallelizable and loss-tolerant.

Output Feedback Mode – 
The output feedback mode follows nearly the same process as the Cipher Feedback mode except that it sends the encrypted output as feedback instead of the actual cipher which is XOR output. In this output feedback mode, all bits of the block are sent instead of sending selected s bits. The Output Feedback mode of block cipher holds great resistance towards bit transmission errors. It also decreases the dependency or relationship of the cipher on the plaintext. 
 

Advantages of OFB –

  • In the case of CFB, a single bit error in a block is propagated to all subsequent blocks. This problem is solved by OFB as it is free from bit errors in the plaintext block. 

Disadvantages of OFB-

  • The drawback of OFB is that, because to its operational modes, it is more susceptible to a message stream modification attack than CFB.

Counter Mode – 
The Counter Mode or CTR is a simple counter-based block cipher implementation. Every time a counter-initiated value is encrypted and given as input to XOR with plaintext which results in ciphertext block. The CTR mode is independent of feedback use and thus can be implemented in parallel. 

Its simple implementation is shown below: 

Advantages of Counter –

  •  Since there is a different counter value for each block, the direct plaintext and ciphertext relationship is avoided. This means that the same plain text can map to different ciphertext.
  • Parallel execution of encryption is possible as outputs from previous stages are not chained as in the case of CBC. 

Disadvantages of Counter-

  • The fact that CTR mode requires a synchronous counter at both the transmitter and the receiver is a severe drawback. The recovery of plaintext is erroneous when synchronisation is lost. 

Applications of Block Ciphers

  1. Data Encryption: Block Ciphers are widely used for the encryption of private and sensitive data such as passwords, credit card details and other information that is transmitted or stored for a communication. This encryption process  converts a plain data into non-readable and complex form. Encrypted data can be decrypted only by the authorised person with the private keys.
  2. File and Disk Encryption: Block Ciphers are used for encryption of entire files and disks in order to protect their contents and restrict from unauthorised users. The disk encryption softwares such as BitLocker, TrueCrypt aslo uses block cipher to encrypt data and make it secure.
  3. Virtual Private Networks (VPN): Virtual Private Networks (VPN) use block cipher for the encryption of data that is being transmitted between the two communicating devices over the internet. This process makes sure that data is not accessed by unauthorised person when it is being transmitted to another user.
  4. Secure Sockets Layer (SSL) and Transport Layer Security (TLS): SSL and TLS protocols use block ciphers for encryption of data that is transmitted between web browsers and servers over the internet. This encryption process provides security to confidential data such as login credentials, card information etc.  
  5. Digital Signatures:  Block ciphers are used in the digital signature algorithms, to provide authenticity and integrity to the digital documents. This encryption process generates the unique signature for each document that is used for verifying the authenticity and detecting if any malicious activity is detected.  

Previous Article
Next Article

Similar Reads

Latin alphabet cipher
The Latin Alphabet Cipher Encryption Technique is one of the earliest and simplest techniques of encrypting data. It’s simply a type of substitution cipher technique, i.e., each letter of a given text is substituted by its corresponding number as represented in its alphabetical order. For Example, we have given a string as "hello everyone", then it
5 min read
Program to perform a letter frequency attack on a monoalphabetic substitution cipher
Given a string S of size N representing a monoalphabetic cipher, the task is to print the top five possible plain texts that can be decrypted from the given monoalphabetic cipher using a letter frequency attack. Examples: Input: S = "ETAOINSHRDLCUMWFGYPBVKJXQZ"Output: A SIMPLE MESSAGE B TJNQMF NFTTBHF A SIMPLE MESSAGE C UKORNG OGUUCIG C UKORNG OGUU
13 min read
Rail Fence Cipher - Encryption and Decryption
Given a plain-text message and a numeric key, cipher/de-cipher the given text using Rail Fence algorithm. The rail fence cipher (also called a zigzag cipher) is a form of transposition cipher. It derives its name from the way in which it is encoded. Examples:  EncryptionInput : "GeeksforGeeks "Key = 3Output : GsGsekfrek eoeDecryptionInput : GsGsekf
15 min read
ROT13 cipher
ROT13 cipher(read as - "rotate by 13 places") is a special case of the Ceaser cipher in which the shift is always 13. So every letter is shifted 13 places to encrypt or to decrypt the message. You must think that it is just another caesar cipher so what's different this time? Well the difference is in its implementation. The approach is to use two
10 min read
Baconian Cipher
Bacon's cipher or the Baconian cipher is a method of steganography (a method of hiding a secret message as opposed to just a cipher) devised by Francis Bacon in 1605. A message is concealed in the presentation of text, rather than its content. The Baconian cipher is a substitution cipher in which each letter is replaced by a sequence of 5 character
5 min read
Puzzle | Measuring Block
Assume that you have a block weighing 40 kg and have tools to divide it as you want. Now, your task is to cut that block into 4 pieces such that only using those 4 pieces and a two-way balancing pan, you can measure any weight from 1 kg to 40 kg ? (You should be able to measure any weight like 1 kg, 2 kg, 3 kg upto 40 kg ). Solution: Now since you
2 min read
8085 program to perform AND operation in nibbles of 8 bit number
Problem - Write an assembly language program in 8085 microprocessor to perform AND operation between lower and higher order nibble of 8 bit number. Example - Assumption - 8 bit number is stored at memory location 2050. Final result is stored at memory location 3050. Algorithm - Load the content of memory location 2050 in A. Perform masking of nibbl
2 min read
Count pairs from two arrays whose modulo operation yields K
Given an integer [Tex]k [/Tex]and two arrays [Tex]arr1 [/Tex]and [Tex]arr2 [/Tex], the task is to count the total pairs (formed after choosing an element from [Tex]arr1 [/Tex]and another from [Tex]arr2 [/Tex]) from these arrays whose modulo operation yields [Tex]k [/Tex]. Note: If in a pair (a, b), a > b then the modulo must be performed as a %
6 min read
HDFS - Data Read Operation
HDFS is a distributed file system that stores data over a network of commodity machines. HDFS works on the streaming data access pattern means it supports write-ones and read-many features. Read operation on HDFS is very important and also very much necessary for us to know while working on HDFS that how actually reading is done on HDFS(Hadoop Dist
4 min read
Check if X can be converted to Y by converting to 3 * (X / 2) or X - 1 in each operation
Given two positive integers X and Y, the task is to check if X can be converted to Y or not by repeatedly changing the value of X to (3 * X / 2) (if X is even) or (X - 1). If it is possible to convert X into Y, then print "Yes". Otherwise, print "No". Examples: Input: X = 6, Y = 8Output: YesExplanation:Operation 1: Convert X(= 6) to 3*X/2 ( = 3 * (
5 min read
Introduction to Electronic Mail
Introduction:Electronic mail, commonly known as email, is a method of exchanging messages over the internet. Here are the basics of email:An email address: This is a unique identifier for each user, typically in the format of name@domain.com.An email client: This is a software program used to send, receive and manage emails, such as Gmail, Outlook,
4 min read
Spatial Filtering and its Types
Spatial Filtering technique is used directly on pixels of an image. Mask is usually considered to be added in size so that it has specific center pixel. This mask is moved on the image such that the center of the mask traverses all image pixels. Classification on the basis of Linearity There are two types: 1. Linear Spatial Filter2. Non-linear Spat
3 min read
Java IO : Input-output in Java with Examples
Java brings various Streams with its I/O package that helps the user to perform all the input-output operations. These streams support all the types of objects, data-types, characters, files etc to fully execute the I/O operations. Before exploring various input and output streams lets look at 3 standard or default streams that Java has to provide
7 min read
Building Heap from Array
Given an array of N elements. The task is to build a Binary Heap from the given array. The heap can be either Max Heap or Min Heap. Examples: Input: arr[] = {4, 10, 3, 5, 1}Output: Corresponding Max-Heap: 10 / \ 5 3 / \4 1 Input: arr[] = {1, 3, 5, 4, 6, 13, 10, 9, 8, 15, 17}Output: Corresponding Max-Heap: 17 / \ 15 13 / \ / \ 9 6 5 10 / \ / \ 4 8 3
14 min read
Insertion and Deletion in Heaps
Deletion in Heap:Given a Binary Heap and an element present in the given Heap. The task is to delete an element from this Heap. The standard deletion operation on Heap is to delete the element present at the root node of the Heap. That is if it is a Max Heap, the standard deletion operation will delete the maximum element and if it is a Min heap, i
15+ min read
Association Rule
Association rule mining finds interesting associations and relationships among large sets of data items. This rule shows how frequently a itemset occurs in a transaction. A typical example is a Market Based Analysis. Market Based Analysis is one of the key techniques used by large relations to show associations between items.It allows retailers to
3 min read
Data encryption standard (DES) | Set 1
This article talks about the Data Encryption Standard (DES), a historic encryption algorithm known for its 56-bit key length. We explore its operation, key transformation, and encryption process, shedding light on its role in data security and its vulnerabilities in today's context. What is DES?Data Encryption Standard (DES) is a block cipher with
15+ min read
Introduction to Internet of Things (IoT) - Set 1
IoT stands for Internet of Things. It refers to the interconnectedness of physical devices, such as appliances and vehicles, that are embedded with software, sensors, and connectivity which enables these objects to connect and exchange data. This technology allows for the collection and sharing of data from a vast network of devices, creating oppor
9 min read
Hypervisor
A hypervisor is a form of virtualization software used in Cloud hosting to divide and allocate the resources on various pieces of hardware. The program which provides partitioning, isolation, or abstraction is called a virtualization hypervisor. The hypervisor is a hardware virtualization technique that allows multiple guest operating systems (OS)
5 min read
Services and Segment structure in TCP
The Transmission Control Protocol is the most common transport layer protocol. It works together with IP and provides a reliable transport service between processes using the network layer service provided by the IP protocol. The various services provided by the TCP to the application layer are as follows: Process-to-Process Communication - TCP pro
5 min read
Block Cipher modes of Operation
Encryption algorithms are divided into two categories based on the input type, as a block cipher and stream cipher. Block cipher is an encryption algorithm that takes a fixed size of input say b bits and produces a ciphertext of b bits again. If the input is larger than b bits it can be divided further. For different applications and uses, there ar
5 min read
Carrier Sense Multiple Access (CSMA)
Carrier Sense Multiple Access (CSMA) is a method used in computer networks to manage how devices share a communication channel to transfer the data between two devices. In this protocol, each device first sense the channel before sending the data. If the channel is busy, the device waits until it is free. This helps reduce collisions, where two dev
9 min read
Ripple Counter in Digital Logic
Counters play a crucial role in digital logic circuits, enabling tasks such as clock frequency division and sequencing. This article explores the concept of ripple counters, a type of asynchronous counter, their operation, advantages, and disadvantages in digital logic design. What is a Counter?Counter is basically used to count the number of clock
5 min read
Converting Context Free Grammar to Chomsky Normal Form
Prerequisite - Simplifying Context Free Grammars A context free grammar (CFG) is in Chomsky Normal Form (CNF) if all production rules satisfy one of the following conditions: A non-terminal generating a terminal (e.g.; X->x) A non-terminal generating two non-terminals (e.g.; X->YZ) Start symbol generating ε. (e.g.; S-> ε) Consider the following gra
4 min read
Computer Architecture | Flynn's taxonomy
Parallel computing is a computing where the jobs are broken into discrete parts that can be executed concurrently. Each part is further broken down to a series of instructions. Instructions from each part execute simultaneously on different CPUs. Parallel systems deal with the simultaneous use of multiple computer resources that can include a singl
4 min read
Carry Look-Ahead Adder
The adder produce carry propagation delay while performing other arithmetic operations like multiplication and divisions as it uses several additions or subtraction steps. This is a major problem for the adder and hence improving the speed of addition will improve the speed of all other arithmetic operations. Hence reducing the carry propagation de
5 min read
Sliding Window Protocol | Set 3 (Selective Repeat)
Prerequisite : Sliding Window Protocol - Set 1 (Sender Side), Set 2 (Receiver Side) Why Selective Repeat Protocol? The go-back-n protocol works well if errors are less, but if the line is poor it wastes a lot of bandwidth on retransmitted frames. An alternative strategy, the selective repeat protocol, is to allow the receiver to accept and buffer t
3 min read
Difference Between Structure and Union in C
Structures in C is a user-defined data type available in C that allows to combining of data items of different kinds. Structures are used to represent a record. Defining a structure: To define a structure, you must use the struct statement. The struct statement defines a new data type, with more than or equal to one member. The format of the struct
4 min read
File Allocation Methods
The allocation methods define how the files are stored in the disk blocks. There are three main disk space or file allocation methods. Contiguous Allocation Linked Allocation Indexed Allocation The main idea behind these methods is to provide: Efficient disk space utilization. Fast access to the file blocks. All the three methods have their own adv
5 min read
SQL Functions (Aggregate and Scalar Functions)
SQL Functions are built-in programs that are used to perform different operations on the database. There are two types of functions in SQL: Aggregate FunctionsScalar FunctionsSQL Aggregate FunctionsSQL Aggregate Functions operate on a data group and return a singular output. They are mostly used with the GROUP BY clause to summarize data.  Some com
4 min read
Article Tags :
Practice Tags :
three90RightbarBannerImg