RC5 is a symmetric key algorithm for block encryption designed by Ron Rivest. It is suitable for both hardware and software implementations due to the following characteristics:
Simplicity: The algorithm only uses primitive computer operations, such as addition, subtraction, bitwise XOR, and circular shifts. This makes it easy to implement and analyze.
Flexibility: It allows a variable number of rounds and bit size of the key.
Low memory utilization: It can be implemented on devices with limited memory.
RC5 is a parameterized, word-oriented algorithm. This means it is a block cipher with a two-word input (plaintext) and a two-word output (ciphertext) block size. The parameters are detailed as follows:
This is the word size in bits. RC5 has two
This is the number of rounds and determines the trade-off between speed and security, where greater rounds imply higher security but lower speed.
This is the number of
The table below summarizes the parameters:
Parameter | Explanation | Accepted values |
w | Word size in bits. | 16, 32, 64 |
r | Number of rounds. | 0–255 |
b | Number of octets (8-bit bytes) in the secret key K. | 0–255 |
Given these parameters, the notation for the algorithm is as follows:
The nominal version of this is
RC5 uses only three primitive operations and their inverses. These are:
Addition: This refers to the two's complement addition of words and is denoted by
Bitwise XOR: This is the bitwise exclusive-OR of words and is denoted by
Left rotation: This is the cyclic left rotation of words, denoted by
Now that we have defined the parameters and operations, we can begin taking a look at the three components of the RC5 encryption algorithm:
Key expansion algorithm
Encryption
Decryption
The diagram below illustrates the order of these components:
Recall that RC5 uses an expanded key table,
RC5 uses two word-sized constants,
Where
For
Word size | P (in hexadecimal) | Q (in hexadecimal) |
16 | b7e1 | 9e37 |
32 | b7e15163 | 9e3779b9 |
64 | b7e151628aed2a6b | 9e3779b97f4a7c15 |
The secret key array,
for i = b-1 to 0:L[i/u] = (L[i/u] <<< 8) + K[i]
This step requires the initialization of the array
S[0] = Pfor i = 0 to t-1:S[i] = S[i-1] + Q
The last step of the key expansion algorithm involves mixing the provided secret key over the arrays
The pseudocode for mixing is as follows:
i = 0j = 0do 3 * max(t, c) times:A = S[i] = (S[i] + A + B) <<< 3B = L[j] = (L[j] + A + B) <<< (A + B)i = (i + 1) % tj = (j + 1) % c
Now that we have the expanded key in the array
A = A + S[0]B = B + S[1]for i = 1 to r:A = ((A ^ B) <<< B) + S[2 * i]B = ((B ^ A) <<< A) + S[2 * i + 1]
Once
The pseudocode for the decryption algorithm is the reverse of the encryption algorithm, as shown:
for i = r to 1:B = ((B - S[2 * i + 1]) >>> A) ^ AA = ((A - S[2 * i]) >>> B) ^ BB = B - S[1]A = A - S[0]
This concludes the overview of the different steps in the RC5 encryption algorithm.
Free Resources