Rivest Cipher 4 (RC4)
Encryption and Decryption
Encryption is the process of converting plaintext to encrypted text. Since encrypted text cannot be read by anyone, encrypted text hides the original data from unauthorized users. Decryption is the process of converting encrypted data to plaintext. Basically, it is the reverse of encryption. It is used to decrypt the encrypted data so that only an authorized user can access and read the data. The process entailing encryption and decryption together is called cryptography.
Private and Public Keys in Cryptography
A key is a bit valued string which is used to convert the plaintext into cipher text and vice-versa. A key can be a word, number or phrase. Cryptography makes use of public and private keys. A public key is issued publicly by the organization and it is used by the end user to encrypt the data. The encrypted data, once received by the organization, is decrypted by using a private key and the data is converted to plaintext.
Encryption Types
Cryptography uses symmetric and asymmetric encryption for encryption and decryption of data. If the sender and the recipient of the data use the same key to encrypt and decrypt the data, it’s called symmetric encryption and if the keys are different for encryption and decryption then its asymmetric encryption.
Now the basics are clear, let’s focus on the RC4 Cipher algorithm in this post.
RC4
RC4 stands for Rivest Cipher 4. RC4 is a stream cipher and was invented by Ron Rivest in 1987. Since RC4 is a stream cipher, it encrypts the stream of data byte by byte. Of all the stream ciphers, RC4 is the widely used stream cipher due to its speed of operations and simplicity.
RC4 Variants
RC4 has 4 variants to it. They are –
- SPRITZ – Spritz is used to build –
- a) Cryptographic hash function
- b) Deterministic random bit generator (DRBG)
- c) Encryption algorithm which supports Authenticated Encryption with Associated Data (AEAD).
- RC4A – This is a stronger variant than RC4.
- VMPC – It stands for Variably Modified Permutation Composition.
- RC4A+ – RC4A+ as the name suggests is a modified version of RC4 with a more complex three-phase key schedule and takes 1.7 times as long as basic RC4.
Working of RC4
RC4 makes use of KSA and PRGA Algorithms. Explanation and working of these algo is out of scope. Let’s understand how encryption and decryption takes place in RC4 –
Encryption
- User inputs a plain text and a secret key.
- Encryption engine generates the keystream by using KSA and PRGA Algorithms for the secret key entered.
- The generated keystream is XORed with the plain text. Since RC4 is a stream cipher, XORing is done byte by byte and encrypted text is produced.
- This encrypted text is now sent to the intended receiver in encrypted form.
Example
Plain Text : 10011001
Keystream : 11000011
——————————–
Cipher Text : 01011010
Decryption
Steps
- For decryption, cipher text and the same keystream is required which was used for encryption.
- The cipher text and the keystream produce plain text using XOR Operation.
- Ciphertext is XOR’ed with keystream bit by bit to produce PlainText.
Example
Cipher Text : 01011010
Keystream : 11000011
———————-
Plain Text : 10011001
Advantages of RC4
- RC4 is simple to use.
- Speed of operation is fast as compared to other cipher suites.
- RC4 cipher is easy to implement.
- RC4 does not consume more memory.
- For large streams of data, RC4 is the preferred choice.
Disadvantages of RC4
- If a strong MAC is not used, RC4 is vulnerable to a bit-flipping attack.
- RC4 does not support authentication.
- RC4 is not feasible to be implemented on small streams of data.
Attacks on RC4
RC4 is vulnerable to following attacks –
- Fluhrer, Mantin and Shamir attack
- Klein’s attack
- Combinatorial Problem
- Royal Holloway Attack
- Bar-mitzvah Attack
- NOMORE Attack
RC4 Applications
RC4 application has been found in –
- WPA
- BitTorrent protocol encryption
- WEP
- Microsoft Office XP
- Microsoft Point-to-Point Encryption
- Transport Layer Security / Secure Sockets Layer
- Secure Shell (optionally)
- Remote Desktop Protocol
- Kerberos
- SASL Mechanism Digest-MD5
- Skype