RC5
RC5 is a symmetric-key block cipher designed by Ronald L. Rivest of the Massachusetts Institute of Technology in 1994, notable for its simplicity, speed, and parameterization to balance security and performance across hardware and software implementations.[1] The algorithm operates on blocks of data using a variable word size w (typically 16, 32, or 64 bits, resulting in block sizes of 32, 64, or 128 bits), a variable number of rounds r (from 0 to 255, with common values of 8 to 16), and a variable key length b (from 0 to 255 bytes, up to 2040 bits), denoted in the form RC5-w/r/b.[2] Its core operations rely on three primitive arithmetic and logical functions—modular addition, XOR, and left rotation—combined with data-dependent rotations to enhance diffusion and confusion in each round.[1] The design of RC5 emphasizes adaptability, allowing users to select parameters based on required security levels and computational resources; for instance, RC5-32/12/16 provides strong protection suitable for replacing older ciphers like DES, while supporting modes such as ECB, CBC, CFB, and OFB for practical applications.[2] Key expansion derives a subkey array S from the user key using fixed constants derived from the golden ratio (φ), ensuring even distribution and resistance to weak keys.[3] Encryption begins by XORing the plaintext block (split into two words A and B) with initial subkeys, followed by r iterations of rotation, addition, and XOR operations that progressively mix the data.[1] RC5 was publicly released to encourage widespread analysis and adoption, with its patent held by RSA Data Security until expiration, and it has been standardized in documents like RFC 2040 for interoperability in protocols.[2] Although not selected for the AES standard due to preferences for fixed-parameter ciphers, RC5 remains influential for its innovative use of rotations and parameter flexibility, influencing subsequent block cipher designs.[3]Introduction
Description
RC5 is a parameterized family of symmetric key block ciphers designed for efficient implementation in both hardware and software environments. Invented by Ronald Rivest of the Massachusetts Institute of Technology, it emphasizes simplicity and adaptability to varying computational resources.[4] The core structure of RC5 operates as an iterative Feistel-like network, processing plaintext blocks consisting of two w-bit words through a variable number of rounds. It relies on just three primitive operations: bitwise exclusive-or (XOR), addition modulo $2^w, and left rotation by a data-dependent amount. These operations enable a streamlined design that promotes both speed and security without complex substitutions or permutations.[4] RC5's flexibility arises from its tunable parameters: the word size w (in bits, typically 16, 32, or 64, yielding a block size of $2w bits), the key length b (in bytes, ranging from 0 to 255), and the number of rounds r (from 0 to 255). The original proposal recommended the configuration RC5-32/12/16, corresponding to a 64-bit block, 128-bit key, and 12 rounds. A key innovation in RC5 is its use of data-dependent rotations, which introduce non-linearity and enhance diffusion across the block.[4]Parameters
RC5 is a parameterized family of block ciphers, with a specific instance denoted as RC5-w/r/b, where w is the word size in bits, r is the number of rounds, and b is the key size in bytes.[5] The word size w determines the length of the words on which operations are performed and thus the block size, which is 2w bits; allowable values are 16, 32, or 64 bits, with 32 bits (yielding a standard 64-bit block) being the nominal choice for most implementations.[5] Smaller w values enable faster execution on hardware with limited word-processing capabilities, while larger w enhances security by increasing the block size and the complexity of arithmetic operations modulo $2^w.[5] The computations involve data-dependent rotations by amounts derived from word additions modulo $2^w, making larger w more computationally intensive due to wider bit rotations and modular additions.[5] The key size b ranges from 0 to 255 bytes (providing key lengths of 0 to 2040 bits in multiples of 8 bits), offering flexibility for varying security needs; a 128-bit key (b=16) is recommended for adequate protection against brute-force attacks.[5] Longer keys increase resistance to exhaustive search but require more time in the key expansion phase, which mixes the key into subkeys using operations scaled to w-bit words.[5] The number of rounds r ranges from 0 to 255, with 12 rounds originally proposed as a balance between security and efficiency; higher r strengthens the cipher against cryptanalytic attacks at the cost of additional iterations of the core mixing operations.[5] In the algorithm's notation, the plaintext (and ciphertext) block is treated as two w-bit words, A and B.[5] The secret key consists of b bytes, which are loaded into an array of c = \lceil b / (w/8) \rceil w-bit words for key expansion.[5] The key expansion produces a subkey array S of 2(r + 1) w-bit words, which are used in the encryption and decryption rounds.[5]History
Development
RC5 was invented by Ronald L. Rivest, a professor at the Massachusetts Institute of Technology, in 1994 as a symmetric-key block cipher designed to address the limitations of older standards like the Data Encryption Standard (DES), which had a fixed key size and was becoming vulnerable to emerging computational threats.[4] Rivest first presented the algorithm at the CRYPTO '94 conference, held in Santa Barbara, California, where it was published in the proceedings as part of Advances in Cryptology.[6] The primary motivations for developing RC5 stemmed from the need for a cipher that could adapt to rapidly evolving processor technologies in the 1990s, offering flexibility in key length, block size, and number of rounds to suit various security requirements without sacrificing performance.[4] Rivest aimed to create an algorithm that was simple and efficient, emphasizing minimal primitive operations—such as exclusive-or, addition modulo $2^w, and data-dependent rotations—to ensure it could be implemented quickly in both software and hardware environments, including on resource-constrained devices like smart cards.[4] This design philosophy was influenced by the simplicity of Rivest's earlier RC4 stream cipher, but adapted for block encryption to provide a versatile alternative to DES amid growing demands for standardized, high-speed cryptography.[7] The initial publication appeared in Rivest's 1994 paper, "The RC5 Encryption Algorithm," which outlined the cipher's parameterized structure (with word size w, rounds r, and key bytes b) tuned for contemporary hardware like 32-bit microprocessors, positioning RC5 for general-purpose adoption in software applications and embedded systems.[4] Early considerations focused on balancing security and speed, with parameters such as RC5-32/12/16 recommended for replacing DES in typical 1990s computing scenarios.[4]Patent and Licensing
The RC5 block cipher is covered by U.S. Patent No. 5,724,428, titled "Block encryption algorithm with data-dependent rotations," invented by Ronald L. Rivest and assigned to RSA Data Security Inc. (later RSA Security). The patent application was filed on November 1, 1995, and granted on March 3, 1998, encompassing the core RC5 algorithm and its variants that employ data-dependent word rotations for encryption.[8] RSA Security managed licensing for RC5 during the patent's term; commercial implementations typically required paid licenses, while non-commercial, academic, and research uses were permitted without fees.[4] This licensing model allowed broad experimentation in open-source and educational contexts but imposed financial barriers on proprietary software and hardware products.[9] The patent term, governed by U.S. law for applications filed after June 8, 1995, extended 20 years from the filing date, resulting in expiration on November 1, 2015. Following expiration, RC5 entered the public domain, eliminating all licensing restrictions and enabling unrestricted global implementation in any context. The patent's enforcement during its active period limited RC5's commercial adoption in the late 1990s and early 2000s, as organizations favored unencumbered alternatives to avoid royalty fees, contributing to the preference for patent-free ciphers like the Advanced Encryption Standard (AES) in standards and products. Post-expiration, while RC5 remains viable for niche applications, its historical licensing constraints have sustained lower prevalence compared to royalty-free successors.Algorithm
Key Expansion
The key expansion in RC5 derives a set of subkeys from the user-provided secret key, producing an array S of t = 2(r + 1) words, where each word is w bits wide and r is the number of rounds.[4] The input is the secret key K, an array of b bytes where $0 < b \leq 255, which is first converted into an array L of c = \lceil b / u \rceil words, with u = w / 8 bytes per word; if necessary, the key is zero-padded to fill the last word.[4] This expansion ensures that the subkeys are thoroughly mixed and diffused, independent of any structure in the original key, to support the cipher's security.[4] The process begins with initializing the subkey array S. The first subkey is set to a magic constant P_w, defined as the odd integer closest to (e - 2) \times 2^w, where e \approx 2.718281828459\ldots is the base of the natural logarithm; for the nominal word size w = 32, P_{32} = 0xB7E15163 in hexadecimal.[4] Subsequent subkeys are then computed iteratively: for i = 1 to t-1, S = S[i-1] + Q_w, where Q_w is another magic constant, the odd integer closest to (\phi - 1) \times 2^w and \phi = (1 + \sqrt{5})/2 \approx 1.618033988749\ldots is the golden ratio; for w = 32, Q_{32} = 0x9E3779B9.[4] These constants are chosen to promote good diffusion properties during the mixing phase that follows.[4] The key mixing step then combines the initialized S with the key words in L through a loop that runs for $3 \times \max(t, c) iterations to ensure even diffusion regardless of the relative sizes of the arrays.[4] Initialize variables A = 0, B = 0, i = 0, and j = 0. For each iteration:Here, \ll denotes left rotation, and all operations are performed modulo $2^w to keep values within word size.[4] The rotation amounts in the mixing—fixed by 3 for S and variable as A + B for L—help avalanche the changes across the subkeys and key words.[4] Once complete, the array S[0 \dots t-1] provides the subkeys used in the encryption process, with even indices typically for additions and odd for XORs in rounds.[4]A ← ((S[i] + A + B) ≪ 3) mod 2^w S[i] ← A i ← (i + 1) mod t B ← ((L[j] + A + B) ≪ (A + B mod 2^w)) mod 2^w L[j] ← B j ← (j + 1) mod cA ← ((S[i] + A + B) ≪ 3) mod 2^w S[i] ← A i ← (i + 1) mod t B ← ((L[j] + A + B) ≪ (A + B mod 2^w)) mod 2^w L[j] ← B j ← (j + 1) mod c
Encryption
The RC5 encryption algorithm operates on a 2w-bit plaintext block, divided into two w-bit words denoted as A and B, where w is the word size (typically 16, 32, or 64 bits). The process utilizes a set of 2(r+1) subkeys derived from the secret key, stored in an array S[0..2r+1], with r being the number of rounds (typically 12 or more). All arithmetic additions are performed modulo $2^w, and left rotations are by an amount taken modulo w to ensure the shift value stays within the word size.[4] Encryption begins with an initialization step to incorporate the initial subkeys:A \leftarrow A + S{{grok:render&&&type=render_inline_citation&&&citation_id=0&&&citation_type=wikipedia}} \pmod{2^w}
B \leftarrow B + S{{grok:render&&&type=render_inline_citation&&&citation_id=1&&&citation_type=wikipedia}} \pmod{2^w}
This primes the data for mixing with the key material.[4] The core of the encryption consists of r iterative rounds, each applying a simple yet effective transformation that leverages data-dependent operations for diffusion and confusion. In round i (for i = 1 to r):
First, update A using an exclusive-or (XOR) of A and B, followed by a left rotation by the value of B (modulo w), and then addition of the corresponding subkey:
A \leftarrow ((A \oplus B) \ll B) + S[2i] \pmod{2^w}
Then, symmetrically update B using the new A:
B \leftarrow ((B \oplus A) \ll A) + S[2i+1] \pmod{2^w}
The data-dependent rotation—where the shift amount is derived directly from the data itself—promotes a strong avalanche effect, ensuring that small changes in the input propagate rapidly through subsequent rounds, enhancing resistance to differential analysis.[4] Following the r rounds, the final values of A and B form the 2w-bit ciphertext block, with no additional transformations applied. The complete encryption pseudocode is as follows:
Here, ⊕ denotes XOR, <<< denotes left rotation, and || denotes concatenation. This structure ensures the algorithm's simplicity while achieving high performance on both hardware and software platforms.[4]A ← A + S[0] (mod 2^w) B ← B + S[1] (mod 2^w) for i = 1 to r do A ← ((A ⊕ B) <<< B) + S[2i] (mod 2^w) B ← ((B ⊕ A) <<< A) + S[2i+1] (mod 2^w) output A || B (as [ciphertext](/page/Ciphertext))A ← A + S[0] (mod 2^w) B ← B + S[1] (mod 2^w) for i = 1 to r do A ← ((A ⊕ B) <<< B) + S[2i] (mod 2^w) B ← ((B ⊕ A) <<< A) + S[2i+1] (mod 2^w) output A || B (as [ciphertext](/page/Ciphertext))