Updated March 27, 2023
Introduction to RC5
RC5 was developed by Ron Rivest. It is a block encryption algorithm based on the symmetric key. The main feature of this is, it is quite fast as it uses only primitive computer operations. It allows a variable number of rounds and variable bit size key to add flexibility. Another advantage of using RC5 is that it requires less memory for execution. This feature enables RC 5 to be used for various purposes like desktop operation, smart cards, etc.
How RC5 Algorithm Works?
In the RC5 algorithm, the input plain text block size, number of rounds and 8-bit bytes of the key can be of variable length. Once the values of this are decided, the values will remain the same for a particular execution of the cryptographic algorithm. The size of plain text block can be of 32 bits, 64 bits or 138 bits. the length of the key can be of 0 to 2040 bits. The output generated by RC5 is the ciphertext which has the size the same as plain text size.
In RC5, the plain text message is divided into two blocks A and B each of 32 bits. Then two subkeys are generated S and S. These two subkeys are added into A and B respectively. This process produces C and D respectively and marks the end of the one-time operation. Then the process of the round begins. In each round, the following operation is performed.
- Bitwise XOR.
- Left circular shift.
- addition to the next subkey, for both C and D. This, is the addition operation, and then the result of the addition mod 2^w is performed.
Let us discuss the above-mentioned process in detail.
One Time Initial Operation
This process involves two steps:
- Step 1: Divide the plain text into two equal sizes block A and B.
- Step 2: Add S to A and S to B.
These operations are of mod 2^32 and generated C and D respectively.
Details of Round
In this section, we will discuss the result for one round. The process for the first round will be the same for other rounds.
- Step 1: XOR C and D
This is the first step in every round where C and D are XOR to form E.
- Step 2: Circular left shift E
The output generated in step 1 i.e. E is now circular left-shifted by D positions.
- Step 3: Add E and next subkey
In this step, E is added to the next subkey to form the F.
- Step 4: XOR D and P
D and P are XORed to from G.
- Step 5: circular left shift G
The output generated in step 4 i.e. G is now circular left-shifted by F position.
- Step 6: Add G and next subkey
In this step, G is added to the next subkey to form the H.
- Step 7: Miscellaneous steps
In these steps, the checking is done to ensure that all-round is done properly. This is performed using the following steps.
- Increment i by 1
- check if i < r
if i is less than r then rename F as C and H as D. If i is greater than r then the process will stop.
In RC5, subkey can be generated in two steps
- Step 1: Subkeys are generated
- Step 2: Subkeys which are generated in step 1 are mixed with the corresponding sub-portions of the original keys.
Modes of RC5 Algorithm
There are 4 modes in RC5 which are as given below.
1. RC5 Block Cipher
This is also called an electronic codebook mode. It encrypts input blocks of a fixed size which is of 2w bits into a ciphertext block of the same length.
2. RC5 CBC
This is a cipher Chaining block for RC5. In this, plain text message whose length is equal to multiple of the RC5 block size is encrypted.
3. RC5 CBC Pad
This is the modified version of the CBC. Here input message can be of any length. The ciphertext is longer than the plain text by at the most the size of a single RC5 block. It uses padding to handle the mismatch of the length. This makes the length of the message equal to the multiple of 2w bits.
4. RC5 CTS
It is also called as a Ciphertext stealing mode. It is similar to an RC5 CBC pad. The length of the plain text message can be of any length and ciphertext is also equal of length.
This is a guide to the RC5. Here we discuss what is RC5 algorithm, how does it work along with its modes which include, RC5 block Cipher, RC5 CBC, RC5 CBC pad, and RC5 CTS. You may also look at the following articles to learn more –